mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] subscription_oca: Migration to 16.0
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Subscription management",
|
"name": "Subscription management",
|
||||||
"summary": "Generate recurring invoices.",
|
"summary": "Generate recurring invoices.",
|
||||||
"version": "15.0.1.0.1",
|
"version": "16.0.1.0.0",
|
||||||
"development_status": "Beta",
|
"development_status": "Beta",
|
||||||
"category": "Subscription Management",
|
"category": "Subscription Management",
|
||||||
"website": "https://github.com/OCA/contract",
|
"website": "https://github.com/OCA/contract",
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class SaleSubscription(models.Model):
|
|||||||
string="Stage",
|
string="Stage",
|
||||||
tracking=True,
|
tracking=True,
|
||||||
group_expand="_read_group_stage_ids",
|
group_expand="_read_group_stage_ids",
|
||||||
store="true",
|
store=True,
|
||||||
)
|
)
|
||||||
stage_str = fields.Char(
|
stage_str = fields.Char(
|
||||||
related="stage_id.name",
|
related="stage_id.name",
|
||||||
@@ -228,7 +228,7 @@ class SaleSubscription(models.Model):
|
|||||||
self.fiscal_position_id = (
|
self.fiscal_position_id = (
|
||||||
self.env["account.fiscal.position"]
|
self.env["account.fiscal.position"]
|
||||||
.with_company(self.company_id)
|
.with_company(self.company_id)
|
||||||
.get_fiscal_position(self.partner_id.id)
|
._get_fiscal_position(self.partner_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
def action_start_subscription(self):
|
def action_start_subscription(self):
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ class SaleSubscriptionLine(models.Model):
|
|||||||
for line in self:
|
for line in self:
|
||||||
fpos = (
|
fpos = (
|
||||||
line.sale_subscription_id.fiscal_position_id
|
line.sale_subscription_id.fiscal_position_id
|
||||||
or line.sale_subscription_id.fiscal_position_id.get_fiscal_position(
|
or line.sale_subscription_id.fiscal_position_id._get_fiscal_position(
|
||||||
line.sale_subscription_id.partner_id.id
|
line.sale_subscription_id.partner_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# If company_id is set, always filter taxes by the company
|
# If company_id is set, always filter taxes by the company
|
||||||
@@ -174,10 +174,9 @@ class SaleSubscriptionLine(models.Model):
|
|||||||
partner_id=record.sale_subscription_id.partner_id.id,
|
partner_id=record.sale_subscription_id.partner_id.id,
|
||||||
date=fields.Datetime.now(),
|
date=fields.Datetime.now(),
|
||||||
uom=record.product_id.uom_id.id,
|
uom=record.product_id.uom_id.id,
|
||||||
).get_product_price_rule(
|
)._get_product_price_rule(
|
||||||
record.product_id,
|
record.product_id,
|
||||||
record.product_uom_qty or 1.0,
|
record.product_uom_qty or 1.0,
|
||||||
record.sale_subscription_id.partner_id,
|
|
||||||
)
|
)
|
||||||
new_list_price, currency = record.with_context(
|
new_list_price, currency = record.with_context(
|
||||||
partner_id=record.sale_subscription_id.partner_id.id,
|
partner_id=record.sale_subscription_id.partner_id.id,
|
||||||
@@ -203,7 +202,7 @@ class SaleSubscriptionLine(models.Model):
|
|||||||
|
|
||||||
def _get_real_price_currency(self, product, rule_id, qty, uom):
|
def _get_real_price_currency(self, product, rule_id, qty, uom):
|
||||||
PricelistItem = self.env["product.pricelist.item"]
|
PricelistItem = self.env["product.pricelist.item"]
|
||||||
field_name = "lst_price"
|
product_price = product.lst_price
|
||||||
currency_id = None
|
currency_id = None
|
||||||
product_currency = product.currency_id
|
product_currency = product.currency_id
|
||||||
if rule_id:
|
if rule_id:
|
||||||
@@ -217,18 +216,18 @@ class SaleSubscriptionLine(models.Model):
|
|||||||
):
|
):
|
||||||
_price, rule_id = pricelist_item.base_pricelist_id.with_context(
|
_price, rule_id = pricelist_item.base_pricelist_id.with_context(
|
||||||
uom=uom.id
|
uom=uom.id
|
||||||
).get_product_price_rule(
|
)._get_product_price_rule(product, qty)
|
||||||
product, qty, self.sale_subscription_id.partner_id
|
|
||||||
)
|
|
||||||
pricelist_item = PricelistItem.browse(rule_id)
|
pricelist_item = PricelistItem.browse(rule_id)
|
||||||
|
|
||||||
if pricelist_item.base == "standard_price":
|
if pricelist_item.base == "standard_price":
|
||||||
field_name = "standard_price"
|
product_price = product.standard_price
|
||||||
product_currency = product.cost_currency_id
|
product_currency = product.cost_currency_id
|
||||||
elif (
|
elif (
|
||||||
pricelist_item.base == "pricelist" and pricelist_item.base_pricelist_id
|
pricelist_item.base == "pricelist" and pricelist_item.base_pricelist_id
|
||||||
):
|
):
|
||||||
field_name = "price"
|
product_price = pricelist_item.base_pricelist_id._get_product_price(
|
||||||
|
product, self.product_uom_qty or 1.0, uom=self.product_id.uom_id
|
||||||
|
)
|
||||||
product = product.with_context(
|
product = product.with_context(
|
||||||
pricelist=pricelist_item.base_pricelist_id.id
|
pricelist=pricelist_item.base_pricelist_id.id
|
||||||
)
|
)
|
||||||
@@ -256,23 +255,21 @@ class SaleSubscriptionLine(models.Model):
|
|||||||
else:
|
else:
|
||||||
uom_factor = 1.0
|
uom_factor = 1.0
|
||||||
|
|
||||||
return product[field_name] * uom_factor * cur_factor, currency_id
|
return product_price * uom_factor * cur_factor, currency_id
|
||||||
|
|
||||||
def _get_display_price(self, product):
|
def _get_display_price(self, product):
|
||||||
if self.sale_subscription_id.pricelist_id.discount_policy == "with_discount":
|
if self.sale_subscription_id.pricelist_id.discount_policy == "with_discount":
|
||||||
return product.with_context(
|
return self.sale_subscription_id.pricelist_id._get_product_price(
|
||||||
pricelist=self.sale_subscription_id.pricelist_id.id,
|
product, self.product_uom_qty or 1.0, uom=self.product_id.uom_id
|
||||||
uom=self.product_id.uom_id.id,
|
)
|
||||||
).price
|
|
||||||
|
|
||||||
final_price, rule_id = self.sale_subscription_id.pricelist_id.with_context(
|
final_price, rule_id = self.sale_subscription_id.pricelist_id.with_context(
|
||||||
partner_id=self.sale_subscription_id.partner_id.id,
|
partner_id=self.sale_subscription_id.partner_id.id,
|
||||||
date=fields.Datetime.now(),
|
date=fields.Datetime.now(),
|
||||||
uom=self.product_id.uom_id.id,
|
uom=self.product_id.uom_id.id,
|
||||||
).get_product_price_rule(
|
)._get_product_price_rule(
|
||||||
product or self.product_id,
|
product or self.product_id,
|
||||||
self.product_uom_qty or 1.0,
|
self.product_uom_qty or 1.0,
|
||||||
self.sale_subscription_id.partner_id,
|
|
||||||
)
|
)
|
||||||
base_price, currency = self.with_context(
|
base_price, currency = self.with_context(
|
||||||
partner_id=self.sale_subscription_id.partner_id.id,
|
partner_id=self.sale_subscription_id.partner_id.id,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class SaleSubscriptionStage(models.Model):
|
|||||||
|
|
||||||
name = fields.Char(required=True, translate=True)
|
name = fields.Char(required=True, translate=True)
|
||||||
sequence = fields.Integer()
|
sequence = fields.Integer()
|
||||||
display_name = fields.Char(string="Display name")
|
display_name = fields.Char(string="Display name", compute="_compute_display_name")
|
||||||
in_progress = fields.Boolean(string="In progress", default=False)
|
in_progress = fields.Boolean(string="In progress", default=False)
|
||||||
fold = fields.Boolean(string="Kanban folded")
|
fold = fields.Boolean(string="Kanban folded")
|
||||||
description = fields.Text(translate=True)
|
description = fields.Text(translate=True)
|
||||||
@@ -27,3 +27,8 @@ class SaleSubscriptionStage(models.Model):
|
|||||||
)
|
)
|
||||||
if len(post_stages) > 1:
|
if len(post_stages) > 1:
|
||||||
raise ValidationError(_("There is already a Closed-type stage declared"))
|
raise ValidationError(_("There is already a Closed-type stage declared"))
|
||||||
|
|
||||||
|
@api.depends("name")
|
||||||
|
def _compute_display_name(self):
|
||||||
|
for stage in self:
|
||||||
|
stage.display_name = stage.name
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
* Carlos Martínez <carlos@domatix.com>
|
* Carlos Martínez <carlos@domatix.com>
|
||||||
|
* Carolina Ferrer <carolina@domatix.com>
|
||||||
|
|
||||||
|
|
||||||
* `Ooops404 <https://www.ooops404.com>`__:
|
* `Ooops404 <https://www.ooops404.com>`__:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ To make a subscription:
|
|||||||
#. Go to *Subscriptions > Configuration > Subscription templates*.
|
#. Go to *Subscriptions > Configuration > Subscription templates*.
|
||||||
#. Create the templates you consider, choosing the billing frequency: daily, monthly... and the method of creating the invoice and/or order.
|
#. Create the templates you consider, choosing the billing frequency: daily, monthly... and the method of creating the invoice and/or order.
|
||||||
#. Go to *Subscription > Subscriptions*.
|
#. Go to *Subscription > Subscriptions*.
|
||||||
#. 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.
|
#. 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.
|
||||||
#. The cron job will also end the subscription if its end date has been reached.
|
#. The cron job will also end the subscription if its end date has been reached.
|
||||||
|
|
||||||
To create subscriptions with the sale of a product:
|
To create subscriptions with the sale of a product:
|
||||||
|
|||||||
@@ -28,13 +28,11 @@
|
|||||||
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
|
||||||
<field
|
<field
|
||||||
name="description"
|
name="description"
|
||||||
placeholder="Add new description..."
|
placeholder="Add new description..."
|
||||||
nolabel="1"
|
nolabel="1"
|
||||||
/>
|
/>
|
||||||
</group>
|
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
<form>
|
<form>
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button
|
<button
|
||||||
name="action_view_product_ids"
|
name="action_view_product_ids"
|
||||||
@@ -35,7 +34,6 @@
|
|||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</group>
|
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
<field
|
<field
|
||||||
@@ -91,13 +89,11 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="Terms and Conditions">
|
<page string="Terms and Conditions">
|
||||||
<group>
|
|
||||||
<field
|
<field
|
||||||
nolabel="1"
|
nolabel="1"
|
||||||
name="description"
|
name="description"
|
||||||
placeholder="Terms and Conditions"
|
placeholder="Terms and Conditions"
|
||||||
/>
|
/>
|
||||||
</group>
|
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
<field
|
<field
|
||||||
name="stage_id"
|
name="stage_id"
|
||||||
widget="statusbar"
|
widget="statusbar"
|
||||||
clickable="1"
|
options="{'fold_field': 'fold', 'clickable': '1'}"
|
||||||
options="{'fold_field': 'fold'}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
@@ -104,6 +103,7 @@
|
|||||||
name="recurring_next_date"
|
name="recurring_next_date"
|
||||||
attrs="{'invisible': ['|', ('recurring_next_date', '=', False), ('in_progress', '=', False)]}"
|
attrs="{'invisible': ['|', ('recurring_next_date', '=', False), ('in_progress', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
|
<field name="company_id" invisible="1" />
|
||||||
<field
|
<field
|
||||||
name="company_id"
|
name="company_id"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
|
|||||||
Reference in New Issue
Block a user