|
3 | 3 | # Copyright 2024 CorporateHub |
4 | 4 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
5 | 5 |
|
6 | | -from odoo import api, models |
| 6 | +from odoo import models |
7 | 7 |
|
8 | 8 |
|
9 | 9 | class ProductProduct(models.Model): |
10 | 10 | _name = "product.product" |
11 | | - _inherit = ["product.product", "product.restricted.qty.mixin"] |
| 11 | + _inherit = ["product.product", "sale.product.restricted.qty.mixin"] |
12 | 12 |
|
13 | | - @api.depends("product_tmpl_id.is_sale_min_qty_set") |
14 | | - def _compute_is_sale_inherited_min_qty_set(self): |
15 | | - return super()._compute_is_sale_inherited_min_qty_set() |
16 | | - |
17 | | - def _get_is_sale_inherited_min_qty_set(self): |
18 | | - if not self.product_tmpl_id: |
19 | | - return super()._get_is_sale_inherited_min_qty_set() |
20 | | - |
21 | | - self.ensure_one() |
22 | | - return self.product_tmpl_id.is_sale_min_qty_set |
23 | | - |
24 | | - @api.depends("product_tmpl_id.sale_min_qty") |
25 | | - def _compute_sale_inherited_min_qty(self): |
26 | | - return super()._compute_sale_inherited_min_qty() |
27 | | - |
28 | | - def _get_sale_inherited_min_qty(self): |
29 | | - if not self.product_tmpl_id: |
30 | | - return super()._get_sale_inherited_min_qty() |
31 | | - |
32 | | - self.ensure_one() |
33 | | - return self.product_tmpl_id.sale_min_qty |
34 | | - |
35 | | - @api.depends("product_tmpl_id.is_sale_restrict_min_qty_set") |
36 | | - def _compute_is_sale_inherited_restrict_min_qty_set(self): |
37 | | - return super()._compute_is_sale_inherited_restrict_min_qty_set() |
38 | | - |
39 | | - def _get_is_sale_inherited_restrict_min_qty_set(self): |
40 | | - if not self.product_tmpl_id: |
41 | | - return super()._get_is_sale_inherited_restrict_min_qty_set() |
42 | | - |
43 | | - self.ensure_one() |
44 | | - return self.product_tmpl_id.is_sale_restrict_min_qty_set |
45 | | - |
46 | | - @api.depends("product_tmpl_id.sale_restrict_min_qty") |
47 | | - def _compute_sale_inherited_restrict_min_qty(self): |
48 | | - return super()._compute_sale_inherited_restrict_min_qty() |
49 | | - |
50 | | - def _get_sale_inherited_restrict_min_qty(self): |
51 | | - if not self.product_tmpl_id: |
52 | | - return super()._get_sale_inherited_restrict_min_qty() |
53 | | - |
54 | | - self.ensure_one() |
55 | | - return self.product_tmpl_id.sale_restrict_min_qty |
56 | | - |
57 | | - @api.depends("product_tmpl_id.is_sale_max_qty_set") |
58 | | - def _compute_is_sale_inherited_max_qty_set(self): |
59 | | - return super()._compute_is_sale_inherited_max_qty_set() |
60 | | - |
61 | | - def _get_is_sale_inherited_max_qty_set(self): |
62 | | - if not self.product_tmpl_id: |
63 | | - return super()._get_is_sale_inherited_max_qty_set() |
64 | | - |
65 | | - self.ensure_one() |
66 | | - return self.product_tmpl_id.is_sale_max_qty_set |
67 | | - |
68 | | - @api.depends("product_tmpl_id.sale_max_qty") |
69 | | - def _compute_sale_inherited_max_qty(self): |
70 | | - return super()._compute_sale_inherited_max_qty() |
71 | | - |
72 | | - def _get_sale_inherited_max_qty(self): |
73 | | - if not self.product_tmpl_id: |
74 | | - return super()._get_sale_inherited_max_qty() |
75 | | - |
76 | | - self.ensure_one() |
77 | | - return self.product_tmpl_id.sale_max_qty |
78 | | - |
79 | | - @api.depends("product_tmpl_id.is_sale_restrict_max_qty_set") |
80 | | - def _compute_is_sale_inherited_restrict_max_qty_set(self): |
81 | | - return super()._compute_is_sale_inherited_restrict_max_qty_set() |
82 | | - |
83 | | - def _get_is_sale_inherited_restrict_max_qty_set(self): |
84 | | - if not self.product_tmpl_id: |
85 | | - return super()._get_is_sale_inherited_restrict_max_qty_set() |
86 | | - |
87 | | - self.ensure_one() |
88 | | - return self.product_tmpl_id.is_sale_restrict_max_qty_set |
89 | | - |
90 | | - @api.depends("product_tmpl_id.sale_restrict_max_qty") |
91 | | - def _compute_sale_inherited_restrict_max_qty(self): |
92 | | - return super()._compute_sale_inherited_restrict_max_qty() |
93 | | - |
94 | | - def _get_sale_inherited_restrict_max_qty(self): |
95 | | - if not self.product_tmpl_id: |
96 | | - return super()._get_sale_inherited_restrict_max_qty() |
97 | | - |
98 | | - self.ensure_one() |
99 | | - return self.product_tmpl_id.sale_restrict_max_qty |
100 | | - |
101 | | - @api.depends("product_tmpl_id.is_sale_multiple_of_qty_set") |
102 | | - def _compute_is_sale_inherited_multiple_of_qty_set(self): |
103 | | - return super()._compute_is_sale_inherited_multiple_of_qty_set() |
104 | | - |
105 | | - def _get_is_sale_inherited_multiple_of_qty_set(self): |
106 | | - if not self.product_tmpl_id: |
107 | | - return super()._get_is_sale_inherited_multiple_of_qty_set() |
108 | | - |
109 | | - self.ensure_one() |
110 | | - return self.product_tmpl_id.is_sale_multiple_of_qty_set |
111 | | - |
112 | | - @api.depends("product_tmpl_id.sale_multiple_of_qty") |
113 | | - def _compute_sale_inherited_multiple_of_qty(self): |
114 | | - return super()._compute_sale_inherited_multiple_of_qty() |
115 | | - |
116 | | - def _get_sale_inherited_multiple_of_qty(self): |
117 | | - if not self.product_tmpl_id: |
118 | | - return super()._get_sale_inherited_multiple_of_qty() |
119 | | - |
120 | | - self.ensure_one() |
121 | | - return self.product_tmpl_id.sale_multiple_of_qty |
122 | | - |
123 | | - @api.depends("product_tmpl_id.is_sale_restrict_multiple_of_qty_set") |
124 | | - def _compute_is_sale_inherited_restrict_multiple_of_qty_set(self): |
125 | | - return super()._compute_is_sale_inherited_restrict_multiple_of_qty_set() |
126 | | - |
127 | | - def _get_is_sale_inherited_restrict_multiple_of_qty_set(self): |
128 | | - if not self.product_tmpl_id: |
129 | | - return super()._get_is_sale_inherited_restrict_multiple_of_qty_set() |
130 | | - |
131 | | - self.ensure_one() |
132 | | - return self.product_tmpl_id.is_sale_restrict_multiple_of_qty_set |
133 | | - |
134 | | - @api.depends("product_tmpl_id.sale_restrict_multiple_of_qty") |
135 | | - def _compute_sale_inherited_restrict_multiple_of_qty(self): |
136 | | - return super()._compute_sale_inherited_restrict_multiple_of_qty() |
137 | | - |
138 | | - def _get_sale_inherited_restrict_multiple_of_qty(self): |
139 | | - if not self.product_tmpl_id: |
140 | | - return super()._get_sale_inherited_restrict_multiple_of_qty() |
141 | | - |
142 | | - self.ensure_one() |
143 | | - return self.product_tmpl_id.sale_restrict_multiple_of_qty |
| 13 | + _sale_restricted_qty_parent_field = "product_tmpl_id" |
0 commit comments