Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PurchaseLine(metaclass=PoolMeta):
- __name__ = 'purchase.line'
- blanket_agreement_line = fields.Many2One(
- 'purchase.blanket_agreement.line', "Purchase Blanket Agreement Line",
- ondelete='RESTRICT',
- domain=[
- If(Eval('purchase_state').in_(['draft', 'quotation']), [
- ('agreement.state', 'in', ['done', 'cancelled', 'running']),
- ('product', '=', Eval('product'))],
- []),
- ('agreement.supplier', '=',
- Eval('_parent_purchase', {}).get('party'),
- ),
- ],
- depends=['product', 'purchase_state'])
- @fields.depends('blanket_agreement_line', '_parent_purchase.party',
- 'purchase', methods=['compute_taxes'])
- def on_change_blanket_agreement_line(self):
- if self.blanket_agreement_line:
- self.product = self.blanket_agreement_line.product
- if not self.description:
- self.description = self.blanket_agreement_line.description
- self.unit = self.blanket_agreement_line.unit
- if not self.unit_price:
- self.unit_price = self.blanket_agreement_line.unit_price
- if not self.quantity:
- self.quantity = self.blanket_agreement_line.remaining_quantity
- self.taxes = self.compute_taxes(self.purchase.party)
- @fields.depends('blanket_agreement_line', 'product')
- def on_change_product(self):
- super().on_change_product()
- if self.blanket_agreement_line:
- if self.product != self.blanket_agreement_line.product:
- self.blanket_agreement_line = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement