Skip to content

Commit

Permalink
merge OCA#446 bso_subscription_cease fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariem ELBERRIRI - BSO committed Dec 4, 2020
2 parents 68d0862 + a78cbe7 commit 0baad9f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Latest (Unreleased)

* #444 bso_sales_process

* #446 bso_subscription_cease

**Build**

**Documentation**
Expand Down
2 changes: 1 addition & 1 deletion odoo/local-src/bso_subscription_cease/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'description': 'Allow cease of a subscription line',
'author': 'BSO',
'website': 'https://www.bsonetwork.com',
'depends': ['bso_sales_process', 'sales_team'],
'depends': ['bso_sales_process', 'sales_team', 'purchase'],
'data': [
'views/sale_subscription.xml',
'views/replace_subscription_line_wizard.xml',
Expand Down
12 changes: 8 additions & 4 deletions odoo/local-src/bso_subscription_cease/models/cease_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class CeaseOrder(models.Model):
requested_date = fields.Date(
string='Requested Date'
)

project_id = fields.Many2one(
string='Project',
related='subscription_id.analytic_account_id',
Expand Down Expand Up @@ -87,7 +86,6 @@ class CeaseOrder(models.Model):
purchase_count = fields.Integer(
string='Purchase Count',
compute='compute_purchase_count',
store=True
)
cease_type = fields.Selection(
[('partial', 'Partial'), ('full', 'Full')],
Expand Down Expand Up @@ -152,7 +150,7 @@ def _compute_loss_mrr_usd(self):

@api.multi
def _get_ac_purchase_ids(self):
return self.env['purchase.order.line'].search(
return self.env['purchase.order.line'].sudo().search(
[('account_analytic_id', '=', self.project_id.id)]).mapped(
'order_id').ids

Expand All @@ -171,7 +169,7 @@ def action_get_purchases(self):
'type': 'ir.actions.act_window',
'target': 'current'}

@api.depends('subscription_id')
@api.multi
def compute_purchase_count(self):
for rec in self:
rec.purchase_count = len(rec._get_ac_purchase_ids())
Expand Down Expand Up @@ -206,3 +204,9 @@ def _update_subscription(self):
'subscription_line_id').ids]
return self.subscription_id.sudo().write(
{'recurring_invoice_line_ids': to_remove})

@api.model
def create(self, vals):
res = super(CeaseOrder, self).create(vals)
res.write({'name': '{0}{1:05d}'.format('CO', res.id)})
return res
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def cease_action(self):
'reason_description': self.reason_description,
'cease_line_ids': [(6, 0, cease_lines)]
})
cease_id.write({'name': '{0}{1:05d}'.format('CO', cease_id.id)})

if len(self.subscription_id.recurring_invoice_line_ids) == len(
self.subscription_line_ids):
Expand Down
5 changes: 3 additions & 2 deletions odoo/local-src/bso_subscription_cease/views/cease_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
string="Cease"
type="object"
class="btn-primary"
attrs="{'invisible': [('state', '!=', 'confirm')]}"
attrs="{'invisible':[('state', '!=', 'confirm')]}"
/>
<field name="state" widget="statusbar"
statusbar_visible="draft,confirm,cease"/>
Expand All @@ -25,7 +25,8 @@
<button name="action_get_purchases"
type="object"
icon="fa-credit-card"
class="oe_stat_button">
class="oe_stat_button"
groups="purchase.group_purchase_user">
<field name="purchase_count"
widget="statinfo"
string="Purchases"/>
Expand Down
1 change: 1 addition & 0 deletions odoo/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -727,3 +727,4 @@ migration:
upgrade:
- bso_sales_process
- bso_invoice_lead_notification
- bso_subscription_cease

0 comments on commit 0baad9f

Please sign in to comment.