[IMP] purchase_usability: add invoice_status on PO line
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
from odoo.tools.misc import formatLang
|
from odoo.tools.misc import formatLang
|
||||||
|
from odoo.tools import float_is_zero
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrder(models.Model):
|
class PurchaseOrder(models.Model):
|
||||||
@@ -73,3 +74,33 @@ class PurchaseOrderLine(models.Model):
|
|||||||
|
|
||||||
# for optional display in tree view
|
# for optional display in tree view
|
||||||
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
||||||
|
invoice_status = fields.Selection(
|
||||||
|
[
|
||||||
|
("no", "Nothing to Bill"),
|
||||||
|
("to invoice", "Waiting Bills"),
|
||||||
|
("invoiced", "Fully Billed"),
|
||||||
|
],
|
||||||
|
string="Billing Status",
|
||||||
|
compute="_compute_invoice_status",
|
||||||
|
store=True,
|
||||||
|
readonly=True,
|
||||||
|
default="no",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("state", "qty_to_invoice", "qty_invoiced")
|
||||||
|
def _compute_invoice_status(self):
|
||||||
|
"""Mimic PO '_get_invoiced' method to compute PO line invoice status"""
|
||||||
|
prec = self.env["decimal.precision"].precision_get("Product Unit of Measure")
|
||||||
|
for line in self:
|
||||||
|
if line.state not in ("purchase", "done") or line.display_type:
|
||||||
|
line.invoice_status = "no"
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not float_is_zero(line.qty_to_invoice, precision_digits=prec):
|
||||||
|
line.invoice_status = "to invoice"
|
||||||
|
elif float_is_zero(
|
||||||
|
line.qty_to_invoice, precision_digits=prec
|
||||||
|
) and not float_is_zero(line.qty_invoiced, precision_digits=prec):
|
||||||
|
line.invoice_status = "invoiced"
|
||||||
|
else:
|
||||||
|
line.invoice_status = "no"
|
||||||
|
|||||||
@@ -131,7 +131,10 @@
|
|||||||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||||
</field>
|
</field>
|
||||||
<field name="date_planned" position="after">
|
<field name="date_planned" position="after">
|
||||||
<field name="state"/>
|
<field name="state" decoration-success="state == 'purchase' or state == 'done'" decoration-warning="state == 'to approve'"
|
||||||
|
decoration-info="state == 'draft' or state == 'sent'" optional="show" widget="badge" />
|
||||||
|
<field name="invoice_status" decoration-success="invoice_status == 'invoiced'" decoration-info="invoice_status == 'to invoice'"
|
||||||
|
optional="show" widget="badge" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -144,7 +147,13 @@
|
|||||||
<field name="partner_id" position="after">
|
<field name="partner_id" position="after">
|
||||||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||||
</field>
|
</field>
|
||||||
|
<xpath expr="//filter[@name='hide_cancelled']" position="after">
|
||||||
|
<separator/>
|
||||||
|
<filter name="not_invoiced" string="Waiting Bills" domain="[('invoice_status', '=', 'to invoice')]" />
|
||||||
|
<filter name="invoiced" string="Bills Received" domain="[('invoice_status', '=', 'invoiced')]" />
|
||||||
|
</xpath>
|
||||||
<group expand="0" position="inside">
|
<group expand="0" position="inside">
|
||||||
|
<filter string="Billing Status" name="invoice_status" context="{'group_by' : 'invoice_status'}" />
|
||||||
<filter string="Analytic Account" name="account_analytic_groupby" context="{'group_by': 'account_analytic_id'}" groups="analytic.group_analytic_accounting"/>
|
<filter string="Analytic Account" name="account_analytic_groupby" context="{'group_by': 'account_analytic_id'}" groups="analytic.group_analytic_accounting"/>
|
||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user