can't update the unit price in PO after confirmation


class PurchaseOrder(models.Model):

    _inherit = 'purchase.order'

 

    def _add_supplier_to_product(self):

        super(PurchaseOrder, self)._add_supplier_to_product()

        for line in self.order_line:

            partner = self.partner_id if not self.partner_id.parent_id else self.partner_id.parent_id

            supplier = line.product_id.seller_ids.filtered(lambda x: x.name.id == partner.id)

            if supplier:

                currency = partner.property_purchase_currency_id or self.env.user.company_id.currency_id

                supplier.write({'price': self.currency_id.compute(line.price_unit, currency)})

-------------------------
Thank and Regards,
Jimmy Chu
Genkiware Ltd
Tel: (852) 2356-0023
Email: [email protected]
https://www.genkiware.com/

Room 2967, 29/F, One Pacific Centre
414 Kwun Tong Road, Kwun Tong
Kowloon, Hong Kong

Article Details

Article ID:
23
Category:
Rating :

Related articles