You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							78 lines
						
					
					
						
							3.4 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							78 lines
						
					
					
						
							3.4 KiB
						
					
					
				| # -*- coding: utf-8 -*- | |
| ################################################################################ | |
| # | |
| #    Cybrosys Technologies Pvt. Ltd. | |
| # | |
| #    Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |
| #    Author: MOHAMMED DILSHAD TK (odoo@cybrosys.com) | |
| # | |
| #    You can modify it under the terms of the GNU AFFERO | |
| #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | |
| # | |
| #    This program is distributed in the hope that it will be useful, | |
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |
| #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | |
| # | |
| #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | |
| #    (AGPL v3) along with this program. | |
| #    If not, see <http://www.gnu.org/licenses/>. | |
| # | |
| ################################################################################ | |
| from odoo import models | |
| 
 | |
| 
 | |
| class AccountMoveLine(models.Model): | |
|     _inherit = 'account.move.line' | |
| 
 | |
|     def _create_stock_moves(self, picking): | |
|         """Function to create stock move""" | |
|         done = self.env['stock.move'].browse() | |
|         for line in self: | |
|             price_unit = line.price_unit | |
|             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.rule'].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.rule'].search( | |
|                             [('id', 'in', (2, 3))])])] or [], | |
|                     'warehouse_id': picking.picking_type_id.warehouse_id.id, | |
|                 } | |
|             diff_quantity = line.quantity | |
|             tmp = template.copy() | |
|             tmp.update({ | |
|                 'product_uom_qty': diff_quantity, | |
|             }) | |
|             template['product_uom_qty'] = diff_quantity | |
|             done += self.env['stock.move'].create(template) | |
|         return done
 | |
| 
 |