diff --git a/project_report/report/project_budget_amt_analysis.py b/project_report/report/project_budget_amt_analysis.py
index a60b852..85bf419 100755
--- a/project_report/report/project_budget_amt_analysis.py
+++ b/project_report/report/project_budget_amt_analysis.py
@@ -27,13 +27,16 @@ class BudgetAmtAnalysis(models.Model):
PRO.id AS project_id,
PRO.partner_id AS partner_id,
AAL.employee_id AS employee_id,
- PRO.budgeted_hours AS budgeted_revenue,
- sum(AAL.amount) AS actual_revenue
+ --PRO.budgeted_hours AS budgeted_revenue,
+ --sum(AAL.amount) AS budgeted_revenue
+ SO.amount_total AS budgeted_revenue,
+ SO.amount_total - sum(AAL.amount) AS actual_revenue
FROM project_project PRO
+ LEFT JOIN sale_order SO ON PRO.sale_order_id = SO.id
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id
WHERE AAL.amount < 0.0 AND AAL.project_id IS NOT NULL AND PRO.active = 't' AND PRO.allow_timesheets = 't'
- group by Pro.id, PRO.partner_id, AAL.employee_id, Pro.budgeted_hours, AAL.unit_amount
+ group by Pro.id, PRO.partner_id, AAL.employee_id, Pro.budgeted_hours, AAL.unit_amount, so.amount_total
)""" % (self._table,))
diff --git a/project_report/wizard/project_create_expenses.py b/project_report/wizard/project_create_expenses.py
index 57c352d..57086d5 100644
--- a/project_report/wizard/project_create_expenses.py
+++ b/project_report/wizard/project_create_expenses.py
@@ -39,15 +39,13 @@ class ProjectCreateExpense(models.TransientModel):
percentage_rate = fields.Float(string="Percentage (%)")
expenses_amt = fields.Float(string="Amount", digits=(6, 2), required=True)
- @api.onchange('ispercentage', 'expenses_from', 'percentage_rate', 'per_from_amt')
+ @api.onchange('ispercentage', 'expenses_from')
def onchange_ispercentage(self):
- expense_amount = 0
active_id = self._context.get('active_id')
if self.ispercentage and self.expenses_from:
profit = dict.fromkeys(['invoiced', 'to_invoice'], 0.0)
profitability_raw_data = self.env['project.profitability.report'].read_group([('project_id', '=', active_id)],
['project_id', 'amount_untaxed_to_invoice', 'amount_untaxed_invoiced'], ['project_id'])
- print("profitability_raw_dataprofitability_raw_data", profitability_raw_data)
for data in profitability_raw_data:
profit['invoiced'] += data.get('amount_untaxed_invoiced', 0.0)
profit['to_invoice'] += data.get('amount_untaxed_to_invoice', 0.0)
@@ -55,8 +53,14 @@ class ProjectCreateExpense(models.TransientModel):
self.per_from_amt = profit['invoiced']
if self.expenses_from == 'to_invoice':
self.per_from_amt = profit['to_invoice']
- if self.percentage_rate > 0.0 and self.per_from_amt > 0.0:
- expense_amount = self.per_from_amt * (self.percentage_rate / 100)
+ #if self.percentage_rate > 0.0 and self.per_from_amt > 0.0:
+ #expense_amount = self.per_from_amt * (self.percentage_rate / 100)
+ #self.expenses_amt = expense_amount
+
+ @api.onchange('ispercentage', 'per_from_amt', 'percentage_rate')
+ def onchange_percentage_rate(self):
+ if self.percentage_rate > 0.0 and self.per_from_amt > 0.0:
+ expense_amount = self.per_from_amt * (self.percentage_rate / 100)
self.expenses_amt = expense_amount
diff --git a/project_report/wizard/project_create_expenses_views.xml b/project_report/wizard/project_create_expenses_views.xml
index c437702..e794baa 100644
--- a/project_report/wizard/project_create_expenses_views.xml
+++ b/project_report/wizard/project_create_expenses_views.xml
@@ -14,7 +14,7 @@
-
+
diff --git a/project_report/wizard/project_create_invoice.py b/project_report/wizard/project_create_invoice.py
deleted file mode 100644
index 0584981..0000000
--- a/project_report/wizard/project_create_invoice.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from odoo import api, fields, models, _
-from odoo.exceptions import UserError
-
-
-class ProjectCreateExpenses(models.TransientModel):
- _name = 'project.create.expenses'
- _description = "Create Expenses from project"
-
- @api.model
- def default_get(self, fields):
- result = super(ProjectCreateInvoice, self).default_get(fields)
-
- active_model = self._context.get('active_model')
- if active_model != 'project.project':
- raise UserError(_('You can only apply this action from a project.'))
-
- active_id = self._context.get('active_id')
- if 'project_id' in fields and active_id:
- result['project_id'] = active_id
- return result
-
- project_id = fields.Many2one('project.project', "Project", help="Project to make billable", required=True)
- _candidate_orders = fields.Many2many('sale.order', compute='_compute_candidate_orders')
- sale_order_id = fields.Many2one(
- 'sale.order', string="Choose the Sales Order to invoice", required=True,
- domain="[('id', 'in', _candidate_orders)]"
- )
- amount_to_invoice = fields.Monetary("Amount to invoice", compute='_compute_amount_to_invoice', currency_field='currency_id', help="Total amount to invoice on the sales order, including all items (services, storables, expenses, ...)")
- currency_id = fields.Many2one(related='sale_order_id.currency_id', readonly=True)
-
- @api.depends('project_id.tasks.sale_line_id.order_id.invoice_status')
- def _compute_candidate_orders(self):
- for p in self:
- p._candidate_orders = p.project_id\
- .mapped('tasks.sale_line_id.order_id')\
- .filtered(lambda so: so.invoice_status == 'to invoice')
-
- @api.depends('sale_order_id')
- def _compute_amount_to_invoice(self):
- for wizard in self:
- amount_untaxed = 0.0
- amount_tax = 0.0
- for line in wizard.sale_order_id.order_line.filtered(lambda sol: sol.invoice_status == 'to invoice'):
- amount_untaxed += line.price_reduce * line.qty_to_invoice
- amount_tax += line.price_tax
- wizard.amount_to_invoice = amount_untaxed + amount_tax
-
- def action_create_invoice(self):
- if not self.sale_order_id and self.sale_order_id.invoice_status != 'to invoice':
- raise UserError(_("The selected Sales Order should contain something to invoice."))
- action = self.env["ir.actions.actions"]._for_xml_id("sale.action_view_sale_advance_payment_inv")
- action['context'] = {
- 'active_ids': self.sale_order_id.ids
- }
- return action
diff --git a/project_report/wizard/project_create_invoice_views.xml b/project_report/wizard/project_create_invoice_views.xml
deleted file mode 100644
index 867fb06..0000000
--- a/project_report/wizard/project_create_invoice_views.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- project.create.expense.view.form
- project.create.expense
-
-
-
-
-
-
- Create Expense
- project.create.expense
- form
-
- new
-
-
-