code
unknown
python
4 years ago
1.1 kB
3
Indexable
def _add_product(self, product, qty=0.0): # corresponding_line = self.line_ids.filtered(lambda r: r.product_id.id == product.id and (self.scan_location_id.id == r.location_id.id or not self.scan_location_id)) StockQuant = self.env['stock.quant'] company_id = self.company_id.id if not company_id: company_id = self._uid.company_id.id dom = [('company_id', '=', company_id), ('location_id', '=', self.scan_location_id.id or self.location_id.id), ('lot_id', '=', False), ('product_id','=', product.id), ('owner_id', '=', False), ('package_id', '=', False)] quants = StockQuant.search(dom) th_qty = sum([x.quantity for x in quants]) seq_val = self._set_sequence() self.line_ids += self.line_ids.new({ 'location_id': self.scan_location_id.id or self.location_id.id, 'product_id': product.id, 'product_uom_id': product.uom_id.id, 'theoretical_qty': th_qty, 'product_qty': 0, 'line_sequence': seq_val, }) return True
Editor is loading...