diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-07-02 11:48:35 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-07-02 11:48:35 +0700 |
| commit | dd93d36b4c7cec4e1681d69e296a7cff559386a0 (patch) | |
| tree | 247cf5e739b60592d630b8d86ed6a2be0863dc85 /fixco_custom/models/purchase_order.py | |
| parent | 9c17104f86f116782f0ed36f82d7c3de7130d363 (diff) | |
search invoice marketplace and add discount on order line purchase and add biaya lain lain on purchase
Diffstat (limited to 'fixco_custom/models/purchase_order.py')
| -rw-r--r-- | fixco_custom/models/purchase_order.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/fixco_custom/models/purchase_order.py b/fixco_custom/models/purchase_order.py new file mode 100644 index 0000000..a623ae4 --- /dev/null +++ b/fixco_custom/models/purchase_order.py @@ -0,0 +1,43 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError +from dateutil.relativedelta import relativedelta +from datetime import datetime, timedelta +import logging +from pytz import timezone, utc +import io +import base64 +try: + from odoo.tools.misc import xlsxwriter +except ImportError: + import xlsxwriter + +_logger = logging.getLogger(__name__) + + +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + amount_discount = fields.Monetary( + string='Total Discount', + compute='_compute_amount_discount', + store=True + ) + + biaya_lain_lain = fields.Float( + 'Biaya Lain Lain', + default=0.0, + tracking=True + ) + + @api.depends('order_line.price_total', 'biaya_lain_lain') + def _amount_all(self): + super(PurchaseOrder, self)._amount_all() + + for order in self: + amount_total = order.amount_untaxed + order.amount_tax - order.biaya_lain_lain + order.amount_total = order.currency_id.round(amount_total) + + @api.depends('order_line.discount_amount') + def _compute_amount_discount(self): + for order in self: + order.amount_discount = sum(line.discount_amount for line in order.order_line)
\ No newline at end of file |
