Skip to content

Commit fae3aa7

Browse files
[MIG] subscription_oca: Migration to 16.0
1 parent 6dfa424 commit fae3aa7

10 files changed

+66
-67
lines changed

Diff for: subscription_oca/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Subscription management
33
=======================
44

5-
..
5+
..
66
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!

Diff for: subscription_oca/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Subscription management",
55
"summary": "Generate recurring invoices.",
6-
"version": "15.0.1.0.1",
6+
"version": "16.0.1.0.0",
77
"development_status": "Beta",
88
"category": "Subscription Management",
99
"website": "https://github.com/OCA/contract",

Diff for: subscription_oca/models/sale_subscription.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _read_group_stage_ids(self, stages, domain, order):
114114
string="Stage",
115115
tracking=True,
116116
group_expand="_read_group_stage_ids",
117-
store="true",
117+
store=True,
118118
)
119119
stage_str = fields.Char(
120120
related="stage_id.name",
@@ -228,7 +228,7 @@ def onchange_partner_id_fpos(self):
228228
self.fiscal_position_id = (
229229
self.env["account.fiscal.position"]
230230
.with_company(self.company_id)
231-
.get_fiscal_position(self.partner_id.id)
231+
._get_fiscal_position(self.partner_id)
232232
)
233233

234234
def action_start_subscription(self):

Diff for: subscription_oca/models/sale_subscription_line.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def _compute_tax_ids(self):
9696
for line in self:
9797
fpos = (
9898
line.sale_subscription_id.fiscal_position_id
99-
or line.sale_subscription_id.fiscal_position_id.get_fiscal_position(
100-
line.sale_subscription_id.partner_id.id
99+
or line.sale_subscription_id.fiscal_position_id._get_fiscal_position(
100+
line.sale_subscription_id.partner_id
101101
)
102102
)
103103
# If company_id is set, always filter taxes by the company
@@ -174,10 +174,9 @@ def _compute_discount(self):
174174
partner_id=record.sale_subscription_id.partner_id.id,
175175
date=fields.Datetime.now(),
176176
uom=record.product_id.uom_id.id,
177-
).get_product_price_rule(
177+
)._get_product_price_rule(
178178
record.product_id,
179179
record.product_uom_qty or 1.0,
180-
record.sale_subscription_id.partner_id,
181180
)
182181
new_list_price, currency = record.with_context(
183182
partner_id=record.sale_subscription_id.partner_id.id,
@@ -203,7 +202,7 @@ def _compute_discount(self):
203202

204203
def _get_real_price_currency(self, product, rule_id, qty, uom):
205204
PricelistItem = self.env["product.pricelist.item"]
206-
field_name = "lst_price"
205+
product_price = product.lst_price
207206
currency_id = None
208207
product_currency = product.currency_id
209208
if rule_id:
@@ -217,18 +216,20 @@ def _get_real_price_currency(self, product, rule_id, qty, uom):
217216
):
218217
_price, rule_id = pricelist_item.base_pricelist_id.with_context(
219218
uom=uom.id
220-
).get_product_price_rule(
221-
product, qty, self.sale_subscription_id.partner_id
222-
)
219+
)._get_product_price_rule(product, qty)
223220
pricelist_item = PricelistItem.browse(rule_id)
224221

225222
if pricelist_item.base == "standard_price":
226-
field_name = "standard_price"
223+
product_price = product.standard_price
227224
product_currency = product.cost_currency_id
228225
elif (
229226
pricelist_item.base == "pricelist" and pricelist_item.base_pricelist_id
230227
):
231-
field_name = "price"
228+
product_price = (
229+
pricelist_item.base_pricelist_id._get_product_price(
230+
product, self.product_uom_qty or 1.0, uom=self.product_id.uom_id
231+
)
232+
)
232233
product = product.with_context(
233234
pricelist=pricelist_item.base_pricelist_id.id
234235
)
@@ -256,23 +257,21 @@ def _get_real_price_currency(self, product, rule_id, qty, uom):
256257
else:
257258
uom_factor = 1.0
258259

259-
return product[field_name] * uom_factor * cur_factor, currency_id
260+
return product_price * uom_factor * cur_factor, currency_id
260261

261262
def _get_display_price(self, product):
262263
if self.sale_subscription_id.pricelist_id.discount_policy == "with_discount":
263-
return product.with_context(
264-
pricelist=self.sale_subscription_id.pricelist_id.id,
265-
uom=self.product_id.uom_id.id,
266-
).price
264+
return self.sale_subscription_id.pricelist_id._get_product_price(
265+
product, self.product_uom_qty or 1.0, uom=self.product_id.uom_id
266+
)
267267

268268
final_price, rule_id = self.sale_subscription_id.pricelist_id.with_context(
269269
partner_id=self.sale_subscription_id.partner_id.id,
270270
date=fields.Datetime.now(),
271271
uom=self.product_id.uom_id.id,
272-
).get_product_price_rule(
272+
)._get_product_price_rule(
273273
product or self.product_id,
274274
self.product_uom_qty or 1.0,
275-
self.sale_subscription_id.partner_id,
276275
)
277276
base_price, currency = self.with_context(
278277
partner_id=self.sale_subscription_id.partner_id.id,

Diff for: subscription_oca/models/sale_subscription_stage.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SaleSubscriptionStage(models.Model):
1111

1212
name = fields.Char(required=True, translate=True)
1313
sequence = fields.Integer()
14-
display_name = fields.Char(string="Display name")
14+
display_name = fields.Char(string="Display name", compute="_compute_display_name")
1515
in_progress = fields.Boolean(string="In progress", default=False)
1616
fold = fields.Boolean(string="Kanban folded")
1717
description = fields.Text(translate=True)
@@ -27,3 +27,8 @@ def _check_lot_product(self):
2727
)
2828
if len(post_stages) > 1:
2929
raise ValidationError(_("There is already a Closed-type stage declared"))
30+
31+
@api.depends("name")
32+
def _compute_display_name(self):
33+
for stage in self:
34+
stage.display_name = stage.name

Diff for: subscription_oca/readme/CONTRIBUTORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Carlos Martínez <[email protected]>
2+
* Carolina Ferrer <[email protected]>
23

34

45
* `Ooops404 <https://www.ooops404.com>`__:

Diff for: subscription_oca/readme/USAGE.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ To make a subscription:
33
#. Go to *Subscriptions > Configuration > Subscription templates*.
44
#. Create the templates you consider, choosing the billing frequency: daily, monthly... and the method of creating the invoice and/or order.
55
#. Go to *Subscription > Subscriptions*.
6-
#. Create a subscription and indicate the start date. When the *Subscriptions Management* cron job is executed, the subscription will begin and the first invoice will be created if the execution date matches the start date. The invoice will also be created when the execution date matches the next invoice date. Additionally, you can manually change the subscription status and create an invoice.
6+
#. Create a subscription and indicate the start date. When the *Subscriptions Management* cron job is executed, the subscription will begin and the first invoice will be created if the execution date matches the start date. The invoice will also be created when the execution date matches the next invoice date. Additionally, you can manually change the subscription status and create an invoice by using the *Create Invoice* button. This action creates just an invoice even if the subscription template has the *Sale Order & Invoice* option selected, because the *Invoicing mode* option is triggered through the cron job.
77
#. The cron job will also end the subscription if its end date has been reached.
88

99
To create subscriptions with the sale of a product:

Diff for: subscription_oca/views/sale_subscription_stage_views.xml

+5-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828

2929
</group>
3030
</group>
31-
<group>
32-
<field
33-
name="description"
34-
placeholder="Add new description..."
35-
nolabel="1"
36-
/>
37-
</group>
31+
<field
32+
name="description"
33+
placeholder="Add new description..."
34+
nolabel="1"
35+
/>
3836
</sheet>
3937
</form>
4038
</field>

Diff for: subscription_oca/views/sale_subscription_template_views.xml

+31-35
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,32 @@
88

99
<form>
1010
<sheet>
11-
<group>
12-
<div class="oe_button_box" name="button_box">
13-
<button
14-
name="action_view_product_ids"
15-
type="object"
16-
class="oe_stat_button"
17-
icon="fa-pencil-square-o"
18-
>
19-
<field
20-
name="product_ids_count"
21-
widget="statinfo"
22-
string="Products"
23-
/>
24-
</button>
25-
<button
26-
name="action_view_subscription_ids"
27-
type="object"
28-
class="oe_stat_button"
29-
icon="fa-pencil-square-o"
30-
>
31-
<field
32-
name="subscription_count"
33-
widget="statinfo"
34-
string="Subscriptions"
35-
/>
36-
</button>
37-
</div>
38-
</group>
11+
<div class="oe_button_box" name="button_box">
12+
<button
13+
name="action_view_product_ids"
14+
type="object"
15+
class="oe_stat_button"
16+
icon="fa-pencil-square-o"
17+
>
18+
<field
19+
name="product_ids_count"
20+
widget="statinfo"
21+
string="Products"
22+
/>
23+
</button>
24+
<button
25+
name="action_view_subscription_ids"
26+
type="object"
27+
class="oe_stat_button"
28+
icon="fa-pencil-square-o"
29+
>
30+
<field
31+
name="subscription_count"
32+
widget="statinfo"
33+
string="Subscriptions"
34+
/>
35+
</button>
36+
</div>
3937
<div class="oe_title">
4038
<h1>
4139
<field
@@ -91,13 +89,11 @@
9189
</group>
9290
</page>
9391
<page string="Terms and Conditions">
94-
<group>
95-
<field
96-
nolabel="1"
97-
name="description"
98-
placeholder="Terms and Conditions"
99-
/>
100-
</group>
92+
<field
93+
nolabel="1"
94+
name="description"
95+
placeholder="Terms and Conditions"
96+
/>
10197
</page>
10298
</notebook>
10399

Diff for: subscription_oca/views/sale_subscription_views.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
<field
2727
name="stage_id"
2828
widget="statusbar"
29-
clickable="1"
30-
options="{'fold_field': 'fold'}"
29+
options="{'fold_field': 'fold', 'clickable': '1'}"
3130
/>
3231

3332
</header>
@@ -104,6 +103,7 @@
104103
name="recurring_next_date"
105104
attrs="{'invisible': ['|', ('recurring_next_date', '=', False), ('in_progress', '=', False)]}"
106105
/>
106+
<field name="company_id" invisible="1" />
107107
<field
108108
name="company_id"
109109
options="{'no_create': True}"

0 commit comments

Comments
 (0)