@@ -146,3 +146,38 @@ def test_analytic_propagation_backorder(self):
146
146
backorder .move_raw_ids .analytic_distribution ,
147
147
backorder .analytic_distribution ,
148
148
)
149
+
150
+ def _check_analytic_when_adding_new_line (self ):
151
+ self .production .analytic_distribution = self .analytic_distribution
152
+ self .product_C = self .env ["product.product" ].create (
153
+ {
154
+ "name" : "Product C" ,
155
+ "type" : "product" ,
156
+ "categ_id" : self .product_categ .id ,
157
+ "standard_price" : 50.0 ,
158
+ }
159
+ )
160
+ self .assertGreater (len (self .production .move_raw_ids ), 0 )
161
+ edit_production = Form (self .production )
162
+ with edit_production .move_raw_ids .new () as new_raw :
163
+ new_raw .product_id = self .product_C
164
+ production = edit_production .save ()
165
+ for raw_line in production .move_raw_ids :
166
+ with self .subTest (
167
+ raw_move = raw_line .display_name ,
168
+ raw_product = raw_line .product_id .display_name ,
169
+ ):
170
+ self .assertEqual (
171
+ raw_line .analytic_distribution ,
172
+ self .analytic_distribution ,
173
+ msg = "When a new raw line is added to a draft production, "
174
+ "it should get the analytic distribution of the "
175
+ "production" ,
176
+ )
177
+
178
+ def test_analytic_added_to_new_lines_on_draft (self ):
179
+ self ._check_analytic_when_adding_new_line ()
180
+
181
+ def test_analytic_added_to_new_lines_on_confirmed (self ):
182
+ self .production .action_confirm ()
183
+ self ._check_analytic_when_adding_new_line ()
0 commit comments