I'm trying to look for qty_available
of a product into a specified partner location, I have three Many2one
fields to res.partner
,
printer_book_block = fields.Many2one('res.partner', string="Printer Book Block")
printer_binding = fields.Many2one('res.partner', string="Printer Binding")
printer_edging = fields.Many2one('res.partner', string="Printer Edging")
So, on the lines of this model I should look for those quantities, depending on which res.partner Many2one
has been selected:
order_lines = fields.One2many('bsi.print.order.lines', 'print_order', string="Order lines")
@api.multi
@api.constrains('order_lines', 'order_lines.isbn')
def check_quantity(self):
location = self.printer_book_block.property_stock_supplier.id
for rec in self:
if rec.order_lines:
for line in rec.order_lines:
if line.qty > line.isbn.qty_available in location:
rec.write({'state': 'awaitingraw'})
else:
rec.write({'state': 'work_in_progress',},)
This method should look for qty_available
on printer_book_block.property_stock_supplier
, but it seems like it doesn't really look for that particular location.
The field property_stock_supplier
is a field which is part of res.partner
model, and it specifies the location for every partner as supplier on the system.
Also, how can I specify if one res.partner
has been selected to look specifically for it?
Any ideas?
PS = isbn
is a Many2one
to product.product