|
|
@ -58,18 +58,24 @@ class InvoiceStockMove(models.Model): |
|
|
|
|
|
|
|
def action_stock_move(self): |
|
|
|
for order in self: |
|
|
|
if not self.picking_type_id.default_location_dest_id: |
|
|
|
raise UserError(_( |
|
|
|
" Please set Default Destination Location")) |
|
|
|
|
|
|
|
if not self.invoice_picking_id: |
|
|
|
pick = { |
|
|
|
'picking_type_id': self.picking_type_id.id, |
|
|
|
'partner_id': self.partner_id.id, |
|
|
|
'origin': self.name, |
|
|
|
'location_dest_id': self.picking_type_id.default_location_dest_id.id, |
|
|
|
'location_id': self.partner_id.property_stock_supplier.id |
|
|
|
} |
|
|
|
if self.picking_type_id.code =='outgoing': |
|
|
|
pick = { |
|
|
|
'picking_type_id': self.picking_type_id.id, |
|
|
|
'partner_id': self.partner_id.id, |
|
|
|
'origin': self.name, |
|
|
|
'location_dest_id': self.partner_id.property_stock_customer.id, |
|
|
|
'location_id': self.picking_type_id.default_location_src_id.id |
|
|
|
} |
|
|
|
|
|
|
|
if self.picking_type_id.code =='incoming': |
|
|
|
pick = { |
|
|
|
'picking_type_id': self.picking_type_id.id, |
|
|
|
'partner_id': self.partner_id.id, |
|
|
|
'origin': self.name, |
|
|
|
'location_dest_id': self.picking_type_id.default_location_dest_id.id, |
|
|
|
'location_id': self.partner_id.property_stock_supplier.id |
|
|
|
} |
|
|
|
picking = self.env['stock.picking'].create(pick) |
|
|
|
self.invoice_picking_id = picking.id |
|
|
|
self.picking_count = len(picking) |
|
|
@ -92,7 +98,7 @@ class InvoiceStockMove(models.Model): |
|
|
|
return result |
|
|
|
|
|
|
|
def action_post(self): |
|
|
|
if not self.picking_type_id: |
|
|
|
if not self.picking_type_id : |
|
|
|
raise UserError(_( |
|
|
|
" Please select a picking type")) |
|
|
|
res = super(InvoiceStockMove, self).action_post() |
|
|
@ -107,7 +113,6 @@ class InvoiceStockMove(models.Model): |
|
|
|
('type' & 'reversed_entry_id' are computed in the method). |
|
|
|
:return: An account.move recordset, reverse of the current self. |
|
|
|
''' |
|
|
|
print("Reverse moves", self.picking_type_id) |
|
|
|
|
|
|
|
if self.picking_type_id.code == 'outgoing': |
|
|
|
data = self.env['stock.picking.type'].search([('company_id', '=', self.company_id.id),('code', '=', 'incoming')], limit=1) |
|
|
@ -127,22 +132,38 @@ class SupplierInvoiceLine(models.Model): |
|
|
|
done = self.env['stock.move'].browse() |
|
|
|
for line in self: |
|
|
|
price_unit = line.price_unit |
|
|
|
template = { |
|
|
|
'name': line.name or '', |
|
|
|
'product_id': line.product_id.id, |
|
|
|
'product_uom': line.product_uom_id.id, |
|
|
|
'location_id': line.move_id.partner_id.property_stock_supplier.id, |
|
|
|
'location_dest_id': picking.picking_type_id.default_location_dest_id.id, |
|
|
|
'picking_id': picking.id, |
|
|
|
'state': 'draft', |
|
|
|
'company_id': line.move_id.company_id.id, |
|
|
|
'price_unit': price_unit, |
|
|
|
'picking_type_id': picking.picking_type_id.id, |
|
|
|
'route_ids': 1 and [ |
|
|
|
(6, 0, [x.id for x in self.env['stock.location.route'].search([('id', 'in', (2, 3))])])] or [], |
|
|
|
'warehouse_id': picking.picking_type_id.warehouse_id.id, |
|
|
|
} |
|
|
|
print(template['route_ids'], "two") |
|
|
|
if picking.picking_type_id.code =='outgoing': |
|
|
|
template = { |
|
|
|
'name': line.name or '', |
|
|
|
'product_id': line.product_id.id, |
|
|
|
'product_uom': line.product_uom_id.id, |
|
|
|
'location_id': picking.picking_type_id.default_location_src_id.id, |
|
|
|
'location_dest_id': line.move_id.partner_id.property_stock_customer.id, |
|
|
|
'picking_id': picking.id, |
|
|
|
'state': 'draft', |
|
|
|
'company_id': line.move_id.company_id.id, |
|
|
|
'price_unit': price_unit, |
|
|
|
'picking_type_id': picking.picking_type_id.id, |
|
|
|
'route_ids': 1 and [ |
|
|
|
(6, 0, [x.id for x in self.env['stock.location.route'].search([('id', 'in', (2, 3))])])] or [], |
|
|
|
'warehouse_id': picking.picking_type_id.warehouse_id.id, |
|
|
|
} |
|
|
|
if picking.picking_type_id.code == 'incoming': |
|
|
|
template = { |
|
|
|
'name': line.name or '', |
|
|
|
'product_id': line.product_id.id, |
|
|
|
'product_uom': line.product_uom_id.id, |
|
|
|
'location_id': line.move_id.partner_id.property_stock_supplier.id, |
|
|
|
'location_dest_id': picking.picking_type_id.default_location_dest_id.id, |
|
|
|
'picking_id': picking.id, |
|
|
|
'state': 'draft', |
|
|
|
'company_id': line.move_id.company_id.id, |
|
|
|
'price_unit': price_unit, |
|
|
|
'picking_type_id': picking.picking_type_id.id, |
|
|
|
'route_ids': 1 and [ |
|
|
|
(6, 0, [x.id for x in self.env['stock.location.route'].search([('id', 'in', (2, 3))])])] or [], |
|
|
|
'warehouse_id': picking.picking_type_id.warehouse_id.id, |
|
|
|
} |
|
|
|
diff_quantity = line.quantity |
|
|
|
tmp = template.copy() |
|
|
|
tmp.update({ |
|
|
|