22# - Jordi Ballester Alomar
33# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
44# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
5- from odoo import _ , exceptions , models
5+ from odoo import exceptions , models
66
77
88class StockMove (models .Model ):
@@ -36,36 +36,41 @@ def _generate_valuation_lines_data(
3636 self .operating_unit_id
3737 and self .operating_unit_dest_id
3838 and self .operating_unit_id != self .operating_unit_dest_id
39- and debit_line_vals ["account_id" ] != credit_line_vals ["account_id" ]
39+ and debit_line_vals ["account_id" ]
40+ != credit_line_vals ["account_id" ]
4041 ):
4142 raise exceptions .UserError (
42- _ (
43+ self . env . _ (
4344 "You cannot create stock moves involving separate source"
4445 " and destination accounts related to different "
4546 "operating units."
4647 )
4748 )
4849
4950 if not self .operating_unit_dest_id and not self .operating_unit_id :
50- ou_id = (
51- self .picking_id .picking_type_id .warehouse_id .operating_unit_id .id
52- )
51+ ou_id = self .picking_id .picking_type_id .warehouse_id .operating_unit_id .id
5352 else :
5453 ou_id = False
5554
5655 debit_line_vals ["operating_unit_id" ] = (
57- ou_id or self .operating_unit_dest_id .id or self .operating_unit_id .id
56+ ou_id
57+ or self .operating_unit_dest_id .id
58+ or self .operating_unit_id .id
5859 )
5960 credit_line_vals ["operating_unit_id" ] = (
60- ou_id or self .operating_unit_id .id or self .operating_unit_dest_id .id
61+ ou_id
62+ or self .operating_unit_id .id
63+ or self .operating_unit_dest_id .id
6164 )
6265 rslt = {
6366 "credit_line_vals" : credit_line_vals ,
6467 "debit_line_vals" : debit_line_vals ,
6568 }
6669 if price_diff_line_vals :
6770 price_diff_line_vals ["operating_unit_id" ] = (
68- ou_id or self .operating_unit_id .id or self .operating_unit_dest_id .id
71+ ou_id
72+ or self .operating_unit_id .id
73+ or self .operating_unit_dest_id .id
6974 )
7075 rslt ["price_diff_line_vals" ] = price_diff_line_vals
7176 return rslt
@@ -86,7 +91,8 @@ def _action_done(self, cancel_backorder=False):
8691 # from/to non-internal location
8792 if (
8893 move .location_id .company_id
89- and move .location_id .company_id == move .location_dest_id .company_id
94+ and move .location_id .company_id
95+ == move .location_dest_id .company_id
9096 and move .operating_unit_id != move .operating_unit_dest_id
9197 ):
9298 (
@@ -101,7 +107,8 @@ def _action_done(self, cancel_backorder=False):
101107 move .product_id .standard_price ,
102108 acc_valuation ,
103109 acc_valuation ,
104- _ ("%s - OU Move" ) % move .product_id .display_name ,
110+ self .env ._ ("%s - OU Move" )
111+ % move .product_id .display_name ,
105112 )
106113 am = (
107114 self .env ["account.move" ]
@@ -113,7 +120,8 @@ def _action_done(self, cancel_backorder=False):
113120 "journal_id" : journal_id ,
114121 "line_ids" : move_lines ,
115122 "company_id" : move .company_id .id ,
116- "ref" : move .picking_id and move .picking_id .name ,
123+ "ref" : move .picking_id
124+ and move .picking_id .name ,
117125 "stock_move_id" : move .id ,
118126 }
119127 )
0 commit comments