-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by andhit-r
- Loading branch information
Showing
9 changed files
with
227 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
from . import ( | ||
purchase_order_type, | ||
purchase_order, | ||
purchase_order_line, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2023 OpenSynergy Indonesia | ||
# Copyright 2023 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_name = "purchase.order.line" | ||
_inherit = [ | ||
"purchase.order.line", | ||
] | ||
|
||
percent_invoiced = fields.Float( | ||
string="Percent Invoiced", | ||
compute="_compute_percent_invoiced", | ||
store=True, | ||
compute_sudo=True, | ||
) | ||
|
||
@api.depends( | ||
"qty_invoiced", | ||
"product_uom_qty", | ||
) | ||
def _compute_percent_invoiced(self): | ||
for record in self: | ||
result = 0.0 | ||
if record.product_uom_qty != 0.0: | ||
try: | ||
result = record.qty_invoiced / record.product_uom_qty | ||
except ZeroDivisionError: | ||
result = 0.0 | ||
record.percent_invoiced = result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
from . import ( | ||
stock_warehouse, | ||
res_users, | ||
purchase_order, | ||
purchase_order_line, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2023 OpenSynergy Indonesia | ||
# Copyright 2023 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_name = "purchase.order" | ||
_inherit = [ | ||
"purchase.order", | ||
] | ||
|
||
qty_to_receive = fields.Float( | ||
string="Qty To Receive", | ||
compute="_compute_receive", | ||
store=True, | ||
) | ||
qty_received = fields.Float( | ||
string="Qty Received", | ||
compute="_compute_receive", | ||
store=True, | ||
) | ||
percent_received = fields.Float( | ||
string="Percent Received", | ||
compute="_compute_receive", | ||
store=True, | ||
) | ||
|
||
@api.depends( | ||
"order_line", | ||
"order_line.qty_to_receive", | ||
"order_line.qty_received", | ||
) | ||
def _compute_receive(self): | ||
for record in self: | ||
qty_to_receive = qty_received = percent_received = 0.0 | ||
for line in record.order_line: | ||
qty_to_receive += line.qty_to_receive | ||
qty_received += line.qty_received | ||
if qty_to_receive != 0.0: | ||
try: | ||
percent_received = qty_received / qty_to_receive | ||
except ZeroDivisionError: | ||
percent_received = 0.0 | ||
record.qty_received = qty_received | ||
record.percent_received = percent_received | ||
record.qty_to_receive = qty_to_receive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2023 OpenSynergy Indonesia | ||
# Copyright 2023 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_name = "purchase.order.line" | ||
_inherit = [ | ||
"purchase.order.line", | ||
] | ||
|
||
percent_received = fields.Float( | ||
string="Percent Received", | ||
compute="_compute_receive", | ||
store=True, | ||
compute_sudo=True, | ||
) | ||
qty_to_receive = fields.Float( | ||
string="Qty To Receive", | ||
compute="_compute_receive", | ||
store=True, | ||
compute_sudo=True, | ||
) | ||
|
||
@api.depends( | ||
"qty_received", | ||
"product_uom_qty", | ||
) | ||
def _compute_receive(self): | ||
for record in self: | ||
percent_received = qty_to_receive = qty_recieved = 0.0 | ||
if record.product_id.type != "service": | ||
qty_to_receive = record.product_uom_qty | ||
qty_recieved = record.qty_received | ||
|
||
if qty_to_receive != 0.0: | ||
try: | ||
percent_received = qty_recieved / qty_to_receive | ||
except ZeroDivisionError: | ||
percent_received = 0.0 | ||
record.percent_received = percent_received | ||
record.qty_to_receive = qty_to_receive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2022 OpenSynergy Indonesia | ||
Copyright 2022 PT. Simetri Sinergi Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record id="purchase_order_view_tree" model="ir.ui.view"> | ||
<field name="name">purchase.order.view.tree</field> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="ssi_purchase.purchase_order_view_tree" /> | ||
<field name="priority" eval="100" /> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//field[@name='percent_invoiced']" position="before"> | ||
<field name="percent_received" widget="percentage" /> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
|
||
<record id="purchase_order_view_form1" model="ir.ui.view"> | ||
<field name="name">purchase.order - form</field> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="purchase.purchase_order_form" /> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath | ||
expr="//field[@name='order_line']/tree/field[@name='price_tax']" | ||
position="after" | ||
> | ||
<field name="percent_received" widget="percentage" /> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
|
||
<record id="purchase_order_view_form2" model="ir.ui.view"> | ||
<field name="name">purchase.order - form</field> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="ssi_purchase.purchase_order_form_view_form" /> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//group[@name='group_extra']" position="inside"> | ||
<field name="qty_received" /> | ||
<field name="qty_to_receive" /> | ||
<field name="percent_received" widget="percentage" /> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
</odoo> |