@@ -62,13 +62,6 @@ def _compute_amount_all(self):
6262 required = True ,
6363 )
6464 currency_id = fields .Many2one ("res.currency" , related = "pricelist_id.currency_id" )
65- analytic_account_id = fields .Many2one (
66- comodel_name = "account.analytic.account" ,
67- string = "Analytic Account" ,
68- copy = False ,
69- check_company = True ,
70- domain = "['|', ('company_id', '=', False), ('company_id', '=', company_id)]" ,
71- )
7265 payment_term_id = fields .Many2one (
7366 "account.payment.term" ,
7467 string = "Payment Terms" ,
@@ -243,10 +236,10 @@ def onchange_partner_id(self):
243236 ._get_fiscal_position (self .partner_id ),
244237 }
245238
246- if self .partner_id .user_id :
239+ if user := self .partner_id .user_id :
247240 values ["user_id" ] = self .partner_id .user_id .id
248- if self . partner_id . team_id :
249- values ["team_id" ] = self . partner_id . team_id .id
241+ if user . sale_team_id :
242+ values ["team_id" ] = user . sale_team_id .id
250243 self .update (values )
251244
252245 def unlink (self ):
@@ -273,7 +266,7 @@ def _validate(self):
273266 assert len (order .line_ids ) > 0 , _ ("Must have some lines" )
274267 order .line_ids ._validate ()
275268 except AssertionError as e :
276- raise UserError (e ) from e
269+ raise UserError (e )
277270
278271 def set_to_draft (self ):
279272 for order in self :
@@ -322,7 +315,7 @@ def action_view_sale_orders(self):
322315
323316 def action_view_sale_blanket_order_line (self ):
324317 action = self .env ["ir.actions.act_window" ]._for_xml_id (
325- "sale_blanket_order.act_open_sale_blanket_order_lines_view_tree "
318+ "sale_blanket_order.act_open_sale_blanket_order_lines_view_list "
326319 )
327320 lines = self .mapped ("line_ids" )
328321 if len (lines ) > 0 :
@@ -387,7 +380,9 @@ def _search_remaining_uom_qty(self, operator, value):
387380class BlanketOrderLine (models .Model ):
388381 _name = "sale.blanket.order.line"
389382 _description = "Blanket Order Line"
390- _inherit = ["mail.thread" , "mail.activity.mixin" , "analytic.mixin" ]
383+ _inherit = ["analytic.mixin" ]
384+ _order = "order_id, sequence, id"
385+ _check_company_auto = True
391386
392387 @api .depends (
393388 "original_uom_qty" ,
@@ -505,106 +500,19 @@ def _compute_display_name(self):
505500 else :
506501 return super ()._compute_display_name ()
507502
508- def _get_real_price_currency (self , product , rule_id , qty , uom , pricelist_id ):
509- """Retrieve the price before applying the pricelist
510- :param obj product: object of current product record
511- :param float qty: total quentity of product
512- :param tuple price_and_rule: tuple(price, suitable_rule) coming
513- from pricelist computation
514- :param obj uom: unit of measure of current order line
515- :param integer pricelist_id: pricelist id of sale order"""
516- # Copied and adapted from the sale module
517- PricelistItem = self .env ["product.pricelist.item" ]
518- field_name = "lst_price"
519- currency_id = None
520- product_currency = None
521- if rule_id :
522- pricelist_item = PricelistItem .browse (rule_id )
523- if pricelist_item .pricelist_id .discount_policy == "without_discount" :
524- while (
525- pricelist_item .base == "pricelist"
526- and pricelist_item .base_pricelist_id
527- and pricelist_item .base_pricelist_id .discount_policy
528- == "without_discount"
529- ):
530- price , rule_id = pricelist_item .base_pricelist_id .with_context (
531- uom = uom .id
532- )._get_product_price_rule (product , qty , uom )
533- pricelist_item = PricelistItem .browse (rule_id )
534-
535- if pricelist_item .base == "standard_price" :
536- field_name = "standard_price"
537- if pricelist_item .base == "pricelist" and pricelist_item .base_pricelist_id :
538- field_name = "price"
539- product = product .with_context (
540- pricelist = pricelist_item .base_pricelist_id .id
541- )
542- product_currency = pricelist_item .base_pricelist_id .currency_id
543- currency_id = pricelist_item .pricelist_id .currency_id
544-
545- product_currency = (
546- product_currency
547- or (product .company_id and product .company_id .currency_id )
548- or self .env .company .currency_id
549- )
550- if not currency_id :
551- currency_id = product_currency
552- cur_factor = 1.0
553- else :
554- if currency_id .id == product_currency .id :
555- cur_factor = 1.0
556- else :
557- cur_factor = currency_id ._get_conversion_rate (
558- product_currency , currency_id
559- )
560-
561- product_uom = product .uom_id .id
562- if uom and uom .id != product_uom :
563- # the unit price is in a different uom
564- uom_factor = uom ._compute_price (1.0 , product .uom_id )
565- else :
566- uom_factor = 1.0
567-
568- return product [field_name ] * uom_factor * cur_factor , currency_id .id
569-
570503 def _get_display_price (self ):
571- # Copied and adapted from the sale module
504+ # Compute the display price for blanket order lines
572505 self .ensure_one ()
573506 self .product_id .ensure_one ()
574507
575- pricelist_price = self .pricelist_item_id ._compute_price (
508+ return self .pricelist_item_id ._compute_price (
576509 product = self .product_id ,
577510 quantity = self .original_uom_qty or 1.0 ,
578511 uom = self .product_uom ,
579512 date = fields .Date .today (),
580513 currency = self .currency_id ,
581514 )
582515
583- if self .order_id .pricelist_id .discount_policy == "with_discount" :
584- return pricelist_price
585-
586- if not self .pricelist_item_id :
587- # No pricelist rule found => no discount from pricelist
588- return pricelist_price
589-
590- base_price = self ._get_pricelist_price_before_discount ()
591-
592- # negative discounts (= surcharge) are included in the display price
593- return max (base_price , pricelist_price )
594-
595- def _get_pricelist_price_before_discount (self ):
596- # Copied and adapted from the sale module
597- self .ensure_one ()
598- self .product_id .ensure_one ()
599-
600- return self .pricelist_item_id ._compute_price_before_discount (
601- product = self .product_id ,
602- quantity = self .product_uom_qty or 1.0 ,
603- uom = self .product_uom ,
604- date = fields .Date .today (),
605- currency = self .currency_id ,
606- )
607-
608516 @api .onchange ("product_id" , "original_uom_qty" )
609517 def onchange_product (self ):
610518 precision = self .env ["decimal.precision" ].precision_get (
@@ -687,7 +595,7 @@ def _validate(self):
687595 not line .display_type and line .original_uom_qty > 0.0
688596 ) or line .display_type , _ ("Quantity must be greater than zero" )
689597 except AssertionError as e :
690- raise UserError (e ) from e
598+ raise UserError (str ( e ) ) from e
691599
692600 @api .model_create_multi
693601 def create (self , vals_list ):
0 commit comments