Untitled
unknown
plain_text
a month ago
1.5 kB
3
Indexable
Never
@api.model_create_multi def create(self, vals_list): new_lines = [] for values in vals_list: if values.get('display_type', self.default_get(['display_type'])['display_type']): values.update({ 'product_id': False, 'price_unit': 0, 'product_uom_qty': 0, 'product_uom': False, 'date_planned': False }) else: values.update(self._prepare_add_missing_fields(values)) # Create a new purchase order for each line to avoid grouping order_vals = { 'partner_id': values.get('partner_id'), 'date_order': values.get('date_order'), 'company_id': values.get('company_id'), # Add any other necessary fields here if needed } new_order = self.env['purchase.order'].create(order_vals) values['order_id'] = new_order.id new_line = super(PurchaseOrderLine, self).create([values]) new_lines.extend(new_line) for line in new_line: if line.product_id and line.order_id.state == 'purchase': msg = _("Extra line with %s ") % (line.product_id.display_name,) line.order_id.message_post(body=msg) return new_lines
Leave a Comment