odoo-addon-sale-blanket-order 17.0.1.1.2__py3-none-any.whl → 18.0.1.0.0.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of odoo-addon-sale-blanket-order might be problematic. Click here for more details.

Files changed (26) hide show
  1. odoo/addons/sale_blanket_order/README.rst +15 -15
  2. odoo/addons/sale_blanket_order/__manifest__.py +7 -2
  3. odoo/addons/sale_blanket_order/data/ir_cron.xml +0 -2
  4. odoo/addons/sale_blanket_order/i18n/de.po +0 -15
  5. odoo/addons/sale_blanket_order/i18n/es.po +3 -15
  6. odoo/addons/sale_blanket_order/i18n/fr.po +3 -15
  7. odoo/addons/sale_blanket_order/i18n/fr_FR.po +3 -15
  8. odoo/addons/sale_blanket_order/i18n/it.po +32 -44
  9. odoo/addons/sale_blanket_order/i18n/pt.po +0 -15
  10. odoo/addons/sale_blanket_order/i18n/sale_blanket_order.pot +11 -58
  11. odoo/addons/sale_blanket_order/models/blanket_orders.py +35 -44
  12. odoo/addons/sale_blanket_order/models/sale_orders.py +18 -5
  13. odoo/addons/sale_blanket_order/report/report.xml +0 -2
  14. odoo/addons/sale_blanket_order/report/templates.xml +32 -35
  15. odoo/addons/sale_blanket_order/static/description/index.html +11 -11
  16. odoo/addons/sale_blanket_order/static/src/js/disable_add_order_line.esm.js +26 -0
  17. odoo/addons/sale_blanket_order/tests/test_blanket_orders.py +69 -2
  18. odoo/addons/sale_blanket_order/views/sale_blanket_order_line_views.xml +17 -28
  19. odoo/addons/sale_blanket_order/views/sale_blanket_order_views.xml +14 -25
  20. odoo/addons/sale_blanket_order/views/sale_order_views.xml +2 -14
  21. odoo/addons/sale_blanket_order/wizard/create_sale_orders.py +47 -30
  22. odoo/addons/sale_blanket_order/wizard/create_sale_orders.xml +2 -2
  23. {odoo_addon_sale_blanket_order-17.0.1.1.2.dist-info → odoo_addon_sale_blanket_order-18.0.1.0.0.13.dist-info}/METADATA +19 -19
  24. {odoo_addon_sale_blanket_order-17.0.1.1.2.dist-info → odoo_addon_sale_blanket_order-18.0.1.0.0.13.dist-info}/RECORD +26 -25
  25. {odoo_addon_sale_blanket_order-17.0.1.1.2.dist-info → odoo_addon_sale_blanket_order-18.0.1.0.0.13.dist-info}/WHEEL +1 -1
  26. {odoo_addon_sale_blanket_order-17.0.1.1.2.dist-info → odoo_addon_sale_blanket_order-18.0.1.0.0.13.dist-info}/top_level.txt +0 -0
@@ -372,9 +372,9 @@ ul.auto-toc {
372
372
  !! This file is generated by oca-gen-addon-readme !!
373
373
  !! changes will be overwritten. !!
374
374
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375
- !! source digest: sha256:2f7ee790f62e87ee4b695f21b8be9dd38f8aa7c8fff635d088074823e91dace4
375
+ !! source digest: sha256:f0f9cee803ac6b3a9aaed08fda171398c5febb7e96021d27938e1377ce6a0847
376
376
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377
- <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/17.0/sale_blanket_order"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-17-0/sale-workflow-17-0-sale_blanket_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377
+ <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-blanket/tree/18.0/sale_blanket_order"><img alt="OCA/sale-blanket" src="https://img.shields.io/badge/github-OCA%2Fsale--blanket-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-blanket-18-0/sale-blanket-18-0-sale_blanket_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-blanket&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378
378
  <p>A blanket order is a pre-agreement to sell a certain number of
379
379
  quantities of products at a specific price. From a confirmed blanket
380
380
  order, the users can create new sale orders at such price, until the
@@ -417,7 +417,7 @@ partially deliver the blanket order.</li>
417
417
  blanket orders.</p>
418
418
  <p>To create a new Sale Blanket Order go to the sale menu in the Sales
419
419
  section:</p>
420
- <p><img alt="image1" src="https://raw.githubusercontent.com/OCA/sale-workflow/17.0/sale_blanket_order/static/description/BO_menu.png" /></p>
420
+ <p><img alt="image1" src="https://raw.githubusercontent.com/OCA/sale-blanket/18.0/sale_blanket_order/static/description/BO_menu.png" /></p>
421
421
  <p>Hitting the button create will open the form view in which we can
422
422
  introduce the following information:</p>
423
423
  <ul class="simple">
@@ -433,21 +433,21 @@ introduce the following information:</p>
433
433
  </li>
434
434
  <li>Terms and Conditions of the Blanket Order</li>
435
435
  </ul>
436
- <p><img alt="image2" src="https://raw.githubusercontent.com/OCA/sale-workflow/17.0/sale_blanket_order/static/description/BO_form.png" /></p>
436
+ <p><img alt="image2" src="https://raw.githubusercontent.com/OCA/sale-blanket/18.0/sale_blanket_order/static/description/BO_form.png" /></p>
437
437
  <p>From the form, once the Blanket Order has been confirmed and its state
438
438
  is open, the user can create a Sale Order, check the Sale Orders
439
439
  associated to the Blanket Order and/or see the Blanket Order lines
440
440
  associated to the BO.</p>
441
- <p><img alt="image3" src="https://raw.githubusercontent.com/OCA/sale-workflow/17.0/sale_blanket_order/static/description/BO_actions.png" /></p>
441
+ <p><img alt="image3" src="https://raw.githubusercontent.com/OCA/sale-blanket/18.0/sale_blanket_order/static/description/BO_actions.png" /></p>
442
442
  <p>Hitting the button Create Sale Order will open a wizard that will ask
443
443
  for the amount of each product in the BO lines for which the Sale Order
444
444
  will be created.</p>
445
- <p><img alt="image4" src="https://raw.githubusercontent.com/OCA/sale-workflow/17.0/sale_blanket_order/static/description/PO_from_BO.png" /></p>
445
+ <p><img alt="image4" src="https://raw.githubusercontent.com/OCA/sale-blanket/18.0/sale_blanket_order/static/description/PO_from_BO.png" /></p>
446
446
  <p>Installing this module will add an additional menu which will show all
447
447
  the blanket order lines currently defined in the system. From this list
448
448
  the user can create customized Sale Orders selecting the lines for which
449
449
  the PO (or POs if the customers are different) is (are) created.</p>
450
- <p><img alt="image5" src="https://raw.githubusercontent.com/OCA/sale-workflow/17.0/sale_blanket_order/static/description/BO_lines.png" /></p>
450
+ <p><img alt="image5" src="https://raw.githubusercontent.com/OCA/sale-blanket/18.0/sale_blanket_order/static/description/BO_lines.png" /></p>
451
451
  <p>In the Sale Order form one field is added in the PO lines, the Blanket
452
452
  Order line field. This field keeps track to which Blanket Order line the
453
453
  PO line is associated. Upon adding a new product in a newly created Sale
@@ -457,14 +457,14 @@ factors:</p>
457
457
  <li>Closer Validity date</li>
458
458
  <li>Remaining quantity &gt; Quantity introduced in the Sale Order line</li>
459
459
  </ul>
460
- <p><img alt="image6" src="https://raw.githubusercontent.com/OCA/sale-workflow/17.0/sale_blanket_order/static/description/PO_BOLine.png" /></p>
460
+ <p><img alt="image6" src="https://raw.githubusercontent.com/OCA/sale-blanket/18.0/sale_blanket_order/static/description/PO_BOLine.png" /></p>
461
461
  </div>
462
462
  <div class="section" id="bug-tracker">
463
463
  <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
464
- <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/issues">GitHub Issues</a>.
464
+ <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-blanket/issues">GitHub Issues</a>.
465
465
  In case of trouble, please check there if your issue has already been reported.
466
466
  If you spotted it first, help us to smash it by providing a detailed and welcomed
467
- <a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_blanket_order%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
467
+ <a class="reference external" href="https://github.com/OCA/sale-blanket/issues/new?body=module:%20sale_blanket_order%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
468
468
  <p>Do not contact contributors directly about support or help with technical issues.</p>
469
469
  </div>
470
470
  <div class="section" id="credits">
@@ -517,7 +517,7 @@ by Camptocamp</p>
517
517
  <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
518
518
  mission is to support the collaborative development of Odoo features and
519
519
  promote its widespread use.</p>
520
- <p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/17.0/sale_blanket_order">OCA/sale-workflow</a> project on GitHub.</p>
520
+ <p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-blanket/tree/18.0/sale_blanket_order">OCA/sale-blanket</a> project on GitHub.</p>
521
521
  <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
522
522
  </div>
523
523
  </div>
@@ -0,0 +1,26 @@
1
+ import {KanbanRenderer} from "@web/views/kanban/kanban_renderer";
2
+ import {ListRenderer} from "@web/views/list/list_renderer";
3
+ import {patch} from "@web/core/utils/patch";
4
+
5
+ patch(ListRenderer.prototype, {
6
+ get canCreate() {
7
+ const parentRecord = this.props.list.model.root;
8
+ const disableAddingLines = parentRecord?.data?.disable_adding_lines;
9
+ return !disableAddingLines && super.canCreate;
10
+ },
11
+ });
12
+
13
+ patch(KanbanRenderer.prototype, {
14
+ get canCreate() {
15
+ const parent = this.props.list.model.root;
16
+ const parentModel = parent?.resModel || parent?.model;
17
+ const fieldName = this.props.arch.attrs.name;
18
+
19
+ if (parentModel === "sale.order" && fieldName === "order_line") {
20
+ const disabled = parent.data?.disable_adding_lines;
21
+ return !disabled && super.canCreate;
22
+ }
23
+
24
+ return super.canCreate;
25
+ },
26
+ });
@@ -15,12 +15,65 @@ class TestSaleBlanketOrders(common.TransactionCase):
15
15
  cls.blanket_order_line_obj = cls.env["sale.blanket.order.line"]
16
16
  cls.blanket_order_wiz_obj = cls.env["sale.blanket.order.wizard"]
17
17
  cls.so_obj = cls.env["sale.order"]
18
+ cls.product_pricelist_item_obj = cls.env["product.pricelist.item"]
19
+
20
+ settings = cls.env["res.config.settings"].with_user(cls.env.user).create({})
21
+ settings.group_discount_per_so_line = True
22
+ settings.set_values()
18
23
 
19
24
  cls.payment_term = cls.env.ref("account.account_payment_term_immediate")
20
25
  cls.sale_pricelist = cls.env["product.pricelist"].create(
21
26
  {"name": "Test Pricelist", "currency_id": cls.env.ref("base.USD").id}
22
27
  )
23
28
 
29
+ # Taxes
30
+ company_partner = cls.env["res.partner"].create(
31
+ {
32
+ "name": __name__,
33
+ "country_id": cls.env.company.country_id.id,
34
+ }
35
+ )
36
+ company2 = cls.env["res.company"].create(
37
+ {
38
+ "name": __name__,
39
+ "partner_id": company_partner.id,
40
+ },
41
+ )
42
+ cls.env.user.company_ids += company2
43
+ cls.env = cls.env(
44
+ context=dict(
45
+ cls.env.context, allowed_company_ids=[cls.env.company.id, company2.id]
46
+ )
47
+ )
48
+ tax_group1 = cls.env["account.tax.group"].create(
49
+ {
50
+ "name": cls.env.company.name,
51
+ "company_id": cls.env.company.id,
52
+ }
53
+ )
54
+ tax_group2 = cls.env["account.tax.group"].create(
55
+ {
56
+ "name": company2.name,
57
+ "company_id": company2.id,
58
+ }
59
+ )
60
+ cls.tax1 = cls.env["account.tax"].create(
61
+ {
62
+ "name": cls.env.company.name,
63
+ "company_id": cls.env.company.id,
64
+ "amount": 10,
65
+ "tax_group_id": tax_group1.id,
66
+ }
67
+ )
68
+ cls.tax2 = cls.env["account.tax"].create(
69
+ {
70
+ "name": company2.name,
71
+ "company_id": company2.id,
72
+ "amount": 20,
73
+ "tax_group_id": tax_group2.id,
74
+ }
75
+ )
76
+
24
77
  # UoM
25
78
  cls.categ_unit = cls.env.ref("uom.product_uom_categ_unit")
26
79
  cls.uom_dozen = cls.env["uom.uom"].create(
@@ -48,6 +101,7 @@ class TestSaleBlanketOrders(common.TransactionCase):
48
101
  "type": "consu",
49
102
  "uom_id": cls.env.ref("uom.product_uom_unit").id,
50
103
  "default_code": "PROD_DEL01",
104
+ "taxes_id": [fields.Command.set([cls.tax1.id, cls.tax2.id])],
51
105
  }
52
106
  )
53
107
  cls.product2 = cls.env["product.product"].create(
@@ -94,9 +148,22 @@ class TestSaleBlanketOrders(common.TransactionCase):
94
148
  }
95
149
  )
96
150
  blanket_order.sudo().onchange_partner_id()
97
- blanket_order.pricelist_id.discount_policy = "without_discount"
151
+
152
+ pricelist_item = self.product_pricelist_item_obj.search(
153
+ [("pricelist_id", "=", blanket_order.pricelist_id.id)], limit=1
154
+ )
155
+ if not pricelist_item:
156
+ pricelist_item = self.product_pricelist_item_obj.create(
157
+ {
158
+ "pricelist_id": blanket_order.pricelist_id.id,
159
+ "fixed_price": 10.0,
160
+ }
161
+ )
162
+
98
163
  blanket_order.line_ids[0].sudo().onchange_product()
99
- blanket_order.pricelist_id.discount_policy = "with_discount"
164
+ self.assertEqual(blanket_order.line_ids[0].taxes_id, self.tax1)
165
+
166
+ pricelist_item.write({"compute_price": "percentage"})
100
167
  blanket_order.line_ids[0].sudo().onchange_product()
101
168
  blanket_order.line_ids[0].sudo()._get_display_price()
102
169
 
@@ -1,21 +1,18 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
2
  <odoo>
3
-
4
3
  <!-- VIEWS -->
5
4
 
6
5
  <record id="sale_blanket_order_line_tree" model="ir.ui.view">
7
- <field name="name">sale.blanket.order.line.tree</field>
6
+ <field name="name">sale.blanket.order.line.list</field>
8
7
  <field name="model">sale.blanket.order.line</field>
9
8
  <field name="arch" type="xml">
10
- <tree create="false">
9
+ <list create="false">
11
10
  <field name="sequence" widget="handle" />
12
- <field name="name" invisible="1" />
13
11
  <field name="order_id" />
14
12
  <field
15
13
  name="product_id"
16
14
  context="{'partner_id':parent.partner_id, 'quantity':original_uom_qty, 'company_id': company_id}"
17
15
  />
18
- <field name="product_uom" invisible="1" />
19
16
  <field name="price_unit" />
20
17
  <field name="date_schedule" />
21
18
  <field
@@ -27,8 +24,7 @@
27
24
  <field name="invoiced_uom_qty" />
28
25
  <field name="delivered_uom_qty" />
29
26
  <field name="remaining_uom_qty" />
30
- <field name="company_id" invisible="1" />
31
- </tree>
27
+ </list>
32
28
  </field>
33
29
  </record>
34
30
 
@@ -37,25 +33,23 @@
37
33
  <field name="model">sale.blanket.order.line</field>
38
34
  <field name="priority" eval="20" />
39
35
  <field name="arch" type="xml">
40
- <form string="Sale Blanket Order Line" duplicate="false">
36
+ <form string="Sale Blanket Order Line" duplicate="false" create="false">
41
37
  <sheet>
42
38
  <h1>
43
39
  <field name="order_id" />
44
40
  </h1>
45
41
  <group>
46
42
  <group>
47
- <group>
48
- <field name="product_id" readonly="1" />
49
- <field name="price_unit" readonly="1" />
50
- <field name="partner_id" readonly="1" />
51
- <field name="date_schedule" readonly="1" />
52
- <field
53
- name="company_id"
54
- groups="base.group_multi_company"
55
- optional="show"
56
- options="{'no_create': True}"
57
- />
58
- </group>
43
+ <field name="product_id" readonly="1" />
44
+ <field name="price_unit" readonly="1" />
45
+ <field name="partner_id" readonly="1" />
46
+ <field name="date_schedule" readonly="1" />
47
+ <field
48
+ name="company_id"
49
+ groups="base.group_multi_company"
50
+ optional="show"
51
+ options="{'no_create': True}"
52
+ />
59
53
  </group>
60
54
  <group>
61
55
  <label for="original_uom_qty" />
@@ -128,18 +122,14 @@
128
122
  <page name="sale_lines" string="Sale Order Lines">
129
123
  <field
130
124
  name="sale_lines"
131
- mode="tree"
125
+ mode="list"
132
126
  readonly="1"
133
127
  domain="[('product_id', '=', product_id)]"
134
128
  />
135
129
  </page>
136
130
  </notebook>
137
131
  </sheet>
138
- <div class="oe_chatter">
139
- <field name="message_follower_ids" widget="mail_followers" />
140
- <field name="activity_ids" widget="mail_activity" />
141
- <field name="message_ids" widget="mail_thread" />
142
- </div>
132
+ <chatter />
143
133
  </form>
144
134
  </field>
145
135
  </record>
@@ -165,7 +155,7 @@
165
155
  <field name="name">Blanket Order Lines</field>
166
156
  <field name="type">ir.actions.act_window</field>
167
157
  <field name="res_model">sale.blanket.order.line</field>
168
- <field name="view_mode">tree,form</field>
158
+ <field name="view_mode">list,form</field>
169
159
  <field name="search_view_id" ref="sale_blanket_order_line_search" />
170
160
  </record>
171
161
 
@@ -178,5 +168,4 @@
178
168
  sequence="21"
179
169
  parent="sale.sale_order_menu"
180
170
  />
181
-
182
171
  </odoo>
@@ -1,13 +1,12 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
2
  <odoo>
3
-
4
3
  <!-- VIEWS -->
5
4
 
6
5
  <record id="view_blanket_order_tree" model="ir.ui.view">
7
- <field name="name">sale.blanket.order.tree</field>
6
+ <field name="name">sale.blanket.order.list</field>
8
7
  <field name="model">sale.blanket.order</field>
9
8
  <field name="arch" type="xml">
10
- <tree
9
+ <list
11
10
  decoration-info="state == 'draft'"
12
11
  decoration-muted="state == 'expired'"
13
12
  >
@@ -22,7 +21,7 @@
22
21
  optional="show"
23
22
  readonly="1"
24
23
  />
25
- </tree>
24
+ </list>
26
25
  </field>
27
26
  </record>
28
27
 
@@ -122,7 +121,7 @@
122
121
  readonly="state in ['open', 'done', 'expired']"
123
122
  widget="section_and_note_one2many"
124
123
  >
125
- <tree editable="bottom">
124
+ <list editable="bottom">
126
125
  <control>
127
126
  <create
128
127
  name="add_product_control"
@@ -205,8 +204,8 @@
205
204
  <field
206
205
  name="taxes_id"
207
206
  widget="many2many_tags"
208
- domain="[('type_tax_use','=','sale')]"
209
- context="{'default_type_tax_use': 'sale'}"
207
+ domain="[('type_tax_use', '=', 'sale'), ('company_id', 'parent_of', parent.company_id)]"
208
+ context="{'search_view_ref': 'account.account_tax_view_search'}"
210
209
  options="{'no_create': True}"
211
210
  invisible="display_type"
212
211
  />
@@ -216,7 +215,7 @@
216
215
  invisible="display_type"
217
216
  />
218
217
  <field name="company_id" invisible="1" />
219
- </tree>
218
+ </list>
220
219
  </field>
221
220
  <group class="oe_subtotal_footer oe_right">
222
221
  <field
@@ -263,31 +262,22 @@
263
262
  options="{'no_create': True}"
264
263
  />
265
264
  <field name="client_order_ref" />
265
+ <field
266
+ name="tag_ids"
267
+ widget="many2many_tags"
268
+ options="{'color_field': 'color', 'no_create_edit': True}"
269
+ />
266
270
  <field
267
271
  name="company_id"
268
272
  options="{'no_create': True}"
269
273
  groups="base.group_multi_company"
270
274
  />
271
275
  </group>
272
- <group name="invoicing" string="Invoicing">
273
- <t groups="base.group_multi_company">
274
- <field
275
- name="analytic_account_id"
276
- readonly="sale_count != 0 and state != 'draft'"
277
- groups="analytic.group_analytic_accounting"
278
- force_save="1"
279
- />
280
- </t>
281
- </group>
282
276
  </group>
283
277
  </page>
284
278
  </notebook>
285
279
  </sheet>
286
- <div class="oe_chatter">
287
- <field name="message_follower_ids" />
288
- <field name="activity_ids" />
289
- <field name="message_ids" />
290
- </div>
280
+ <chatter />
291
281
  </form>
292
282
  </field>
293
283
  </record>
@@ -343,7 +333,7 @@
343
333
  <field name="name">Blanket Orders</field>
344
334
  <field name="type">ir.actions.act_window</field>
345
335
  <field name="res_model">sale.blanket.order</field>
346
- <field name="view_mode">tree,form</field>
336
+ <field name="view_mode">list,form</field>
347
337
  <field name="search_view_id" ref="view_blanket_order_search" />
348
338
  <field name="domain">[]</field>
349
339
  <field name="context">{}</field>
@@ -368,5 +358,4 @@
368
358
  sequence="20"
369
359
  action="act_open_blanket_order_view"
370
360
  />
371
-
372
361
  </odoo>
@@ -8,16 +8,6 @@
8
8
  <field name="currency_id" position="after">
9
9
  <field name="blanket_order_id" invisible="1" />
10
10
  </field>
11
- <xpath
12
- expr="//field[@name='order_line']//tree/field[@name='product_id']"
13
- position="after"
14
- >
15
- <field
16
- name="blanket_order_line"
17
- context="{'from_sale_order': True}"
18
- column_invisible="not parent.blanket_order_id"
19
- />
20
- </xpath>
21
11
  <xpath expr="//field[@name='order_line']" position="attributes">
22
12
  <attribute name="context">{'from_sale_order': True}</attribute>
23
13
  </xpath>
@@ -28,10 +18,8 @@
28
18
  <field name="model">sale.order</field>
29
19
  <field name="inherit_id" ref="sale.view_order_form" />
30
20
  <field name="arch" type="xml">
31
- <xpath expr="//field[@name='order_line']//tree" position="attributes">
32
- <t groups="sale_blanket_order.blanket_orders_disable_adding_lines">
33
- <attribute name="create">blanket_order_id==False</attribute>
34
- </t>
21
+ <xpath expr="//field[@name='order_line']" position="before">
22
+ <field name="disable_adding_lines" invisible="1" />
35
23
  </xpath>
36
24
  </field>
37
25
  </record>
@@ -2,7 +2,7 @@
2
2
  # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3
3
  from collections import defaultdict
4
4
 
5
- from odoo import _, api, fields, models
5
+ from odoo import api, fields, models
6
6
  from odoo.exceptions import UserError
7
7
  from odoo.tools import float_is_zero
8
8
 
@@ -22,7 +22,9 @@ class BlanketOrderWizard(models.TransientModel):
22
22
  )
23
23
  if blanket_order.state == "expired":
24
24
  raise UserError(
25
- _("You can't create a sale order from " "an expired blanket order!")
25
+ self.env._(
26
+ "You can't create a sale order from " "an expired blanket order!"
27
+ )
26
28
  )
27
29
  return blanket_order
28
30
 
@@ -37,16 +39,18 @@ class BlanketOrderWizard(models.TransientModel):
37
39
  float_is_zero(line.remaining_uom_qty, precision_digits=precision)
38
40
  for line in bo_lines
39
41
  ):
40
- raise UserError(_("The sale has already been completed."))
42
+ raise UserError(self.env._("The sale has already been completed."))
41
43
 
42
44
  for line in bo_lines:
43
45
  if line.order_id.state != "open":
44
46
  raise UserError(
45
- _("Sale Blanket Order %s is not open") % line.order_id.name
47
+ self.env._("Sale Blanket Order %s is not open") % line.order_id.name
46
48
  )
47
49
  line_company_id = line.company_id and line.company_id.id or False
48
50
  if company_id is not False and line_company_id != company_id:
49
- raise UserError(_("You have to select lines " "from the same company."))
51
+ raise UserError(
52
+ self.env._("You have to select lines " "from the same company.")
53
+ )
50
54
  else:
51
55
  company_id = line_company_id
52
56
 
@@ -66,6 +70,7 @@ class BlanketOrderWizard(models.TransientModel):
66
70
  lines = [
67
71
  fields.Command.create(
68
72
  {
73
+ "analytic_distribution": bol.analytic_distribution,
69
74
  "blanket_line_id": bol.id,
70
75
  "date_schedule": bol.date_schedule,
71
76
  "qty": bol.remaining_uom_qty,
@@ -113,6 +118,8 @@ class BlanketOrderWizard(models.TransientModel):
113
118
  currency_id,
114
119
  pricelist_id,
115
120
  payment_term_id,
121
+ client_order_ref,
122
+ tag_ids,
116
123
  order_lines_by_customer,
117
124
  ):
118
125
  return {
@@ -123,47 +130,55 @@ class BlanketOrderWizard(models.TransientModel):
123
130
  "pricelist_id": pricelist_id,
124
131
  "payment_term_id": payment_term_id,
125
132
  "order_line": order_lines_by_customer[customer],
126
- "analytic_account_id": self.blanket_order_id.analytic_account_id.id,
133
+ "client_order_ref": client_order_ref,
134
+ "tag_ids": [(6, 0, tag_ids.ids)] if tag_ids else False,
127
135
  }
128
136
 
137
+ @api.model
138
+ def _check_consistency(self, current_value, new_value):
139
+ if current_value == 0:
140
+ return new_value
141
+ return current_value if current_value == new_value else False
142
+
129
143
  def create_sale_order(self):
130
144
  order_lines_by_customer = defaultdict(list)
131
145
  currency_id = 0
132
146
  pricelist_id = 0
133
147
  user_id = 0
134
148
  payment_term_id = 0
149
+ client_order_ref = 0
150
+ tag_ids = 0
135
151
  for line in self.line_ids.filtered(lambda line: line.qty != 0.0):
136
152
  if line.qty > line.remaining_uom_qty:
137
- raise UserError(_("You can't order more than the remaining quantities"))
153
+ raise UserError(
154
+ self.env._("You can't order more than the remaining quantities")
155
+ )
138
156
  vals = self._prepare_so_line_vals(line)
139
157
  order_lines_by_customer[line.partner_id.id].append((0, 0, vals))
140
158
 
141
- if currency_id == 0:
142
- currency_id = line.blanket_line_id.order_id.currency_id.id
143
- elif currency_id != line.blanket_line_id.order_id.currency_id.id:
144
- currency_id = False
145
-
146
- if pricelist_id == 0:
147
- pricelist_id = line.blanket_line_id.pricelist_id.id
148
- elif pricelist_id != line.blanket_line_id.pricelist_id.id:
149
- pricelist_id = False
150
-
151
- if user_id == 0:
152
- user_id = line.blanket_line_id.user_id.id
153
- elif user_id != line.blanket_line_id.user_id.id:
154
- user_id = False
155
-
156
- if payment_term_id == 0:
157
- payment_term_id = line.blanket_line_id.payment_term_id.id
158
- elif payment_term_id != line.blanket_line_id.payment_term_id.id:
159
- payment_term_id = False
159
+ currency_id = self._check_consistency(
160
+ currency_id, line.blanket_line_id.order_id.currency_id.id
161
+ )
162
+ pricelist_id = self._check_consistency(
163
+ pricelist_id, line.blanket_line_id.pricelist_id.id
164
+ )
165
+ user_id = self._check_consistency(user_id, line.blanket_line_id.user_id.id)
166
+ payment_term_id = self._check_consistency(
167
+ payment_term_id, line.blanket_line_id.payment_term_id.id
168
+ )
169
+ client_order_ref = self._check_consistency(
170
+ client_order_ref, line.blanket_line_id.order_id.client_order_ref
171
+ )
172
+ tag_ids = self._check_consistency(
173
+ tag_ids, line.blanket_line_id.order_id.tag_ids
174
+ )
160
175
 
161
176
  if not order_lines_by_customer:
162
- raise UserError(_("An order can't be empty"))
177
+ raise UserError(self.env._("An order can't be empty"))
163
178
 
164
179
  if not currency_id:
165
180
  raise UserError(
166
- _(
181
+ self.env._(
167
182
  "Can not create Sale Order from Blanket "
168
183
  "Order lines with different currencies"
169
184
  )
@@ -177,15 +192,17 @@ class BlanketOrderWizard(models.TransientModel):
177
192
  currency_id,
178
193
  pricelist_id,
179
194
  payment_term_id,
195
+ client_order_ref,
196
+ tag_ids,
180
197
  order_lines_by_customer,
181
198
  )
182
199
  sale_order = self.env["sale.order"].create(order_vals)
183
200
  res.append(sale_order.id)
184
201
  return {
185
202
  "domain": [("id", "in", res)],
186
- "name": _("Sales Orders"),
203
+ "name": self.env._("Sales Orders"),
187
204
  "view_type": "form",
188
- "view_mode": "tree,form",
205
+ "view_mode": "list,form",
189
206
  "res_model": "sale.order",
190
207
  "context": {"from_sale_order": True},
191
208
  "type": "ir.actions.act_window",
@@ -7,7 +7,7 @@
7
7
  <form string="Create Sale Order">
8
8
  <group>
9
9
  <field name="line_ids" nolabel="1" colspan="2">
10
- <tree create="false" editable="bottom">
10
+ <list create="false" editable="bottom">
11
11
  <field
12
12
  name="blanket_line_id"
13
13
  force_save="1"
@@ -30,7 +30,7 @@
30
30
  'business_domain': 'sale_order'
31
31
  }"
32
32
  />
33
- </tree>
33
+ </list>
34
34
  </field>
35
35
  </group>
36
36
  <footer>