From 3ff2f81194934726b5dc2d133aec164ba4d889c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 27 Sep 2016 10:59:02 +0200 Subject: [PATCH] [IMP][MOV] portal_sale, sale, account: move portal stuff into right addon * [MOV] sale and invoice portal related code from portal_sale to website_portal_sale. Security rules and website related stuff should indeed be located in website_portal_sale. * [MOV] sale and invoice standard code to sale and account. Adding customer as follower is a standard feature for sale orders and invoices. * [IMP] website_portal_sale does not depend from portal_sale anymore but sale and other portal / website addons --- addons/account/models/account_invoice.py | 3 +++ addons/portal_sale/__manifest__.py | 2 -- addons/portal_sale/models/account_invoice.py | 16 ---------------- addons/portal_sale/models/sale_order.py | 16 ---------------- addons/sale/data/mail_template_data.xml | 2 +- addons/sale/models/sale.py | 2 ++ addons/website_portal_sale/__manifest__.py | 4 +++- .../models/account_invoice.py | 8 ++++++++ addons/website_portal_sale/models/sale_order.py | 8 ++++++++ .../security/sale_order_security.xml} | 0 .../views/sale_order_views.xml | 0 11 files changed, 25 insertions(+), 36 deletions(-) rename addons/{portal_sale/security/portal_sale_security.xml => website_portal_sale/security/sale_order_security.xml} (100%) rename addons/{portal_sale => website_portal_sale}/views/sale_order_views.xml (100%) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index afdd18cbeb8..def1b9484f3 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -884,6 +884,9 @@ class AccountInvoice(models.Model): @api.multi def invoice_validate(self): + for invoice in self.filtered(lambda invoice: invoice.partner_id not in invoice.message_partner_ids): + invoice.message_subscribe([invoice.partner_id.id]) + for invoice in self: #refuse to validate a vendor bill/refund if there already exists one with the same reference for the same partner, #because it's probably a double encoding of the same bill/refund diff --git a/addons/portal_sale/__manifest__.py b/addons/portal_sale/__manifest__.py index 1095b637c22..9eafe9e308f 100644 --- a/addons/portal_sale/__manifest__.py +++ b/addons/portal_sale/__manifest__.py @@ -27,8 +27,6 @@ by default, you simply need to configure a Paypal account in the Accounting/Invo """, 'depends': ['sale', 'portal', 'payment'], 'data': [ - 'security/portal_sale_security.xml', - 'views/sale_order_views.xml', ], 'auto_install': True, 'category': 'Hidden', diff --git a/addons/portal_sale/models/account_invoice.py b/addons/portal_sale/models/account_invoice.py index 628d79d27d3..534062695d5 100644 --- a/addons/portal_sale/models/account_invoice.py +++ b/addons/portal_sale/models/account_invoice.py @@ -6,19 +6,3 @@ from odoo import api, models class AccountInvoice(models.Model): _inherit = 'account.invoice' - - @api.multi - def invoice_validate(self): - # fetch the partner's id and subscribe the partner to the invoice - for invoice in self: - if invoice.partner_id not in invoice.message_partner_ids: - invoice.message_subscribe([invoice.partner_id.id]) - return super(AccountInvoice, self).invoice_validate() - - @api.multi - def get_signup_url(self): - self.ensure_one() - return self.partner_id.with_context(signup_valid=True)._get_signup_url_for_action( - action='/mail/view', - model=self._name, - res_id=self.id)[self.partner_id.id] diff --git a/addons/portal_sale/models/sale_order.py b/addons/portal_sale/models/sale_order.py index b11d000c125..92e1bf0d2f4 100644 --- a/addons/portal_sale/models/sale_order.py +++ b/addons/portal_sale/models/sale_order.py @@ -6,19 +6,3 @@ from odoo import api, models class SaleOrder(models.Model): _inherit = 'sale.order' - - @api.multi - def action_confirm(self): - # fetch the partner's id and subscribe the partner to the sale order - for order in self: - if order.partner_id not in order.message_partner_ids: - order.message_subscribe([order.partner_id.id]) - return super(SaleOrder, self).action_confirm() - - @api.multi - def get_signup_url(self): - self.ensure_one() - return self.partner_id.with_context(signup_valid=True)._get_signup_url_for_action( - action='/mail/view', - model=self._name, - res_id=self.id)[self.partner_id.id] diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index f8c6661d7bb..de2d509539d 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -19,7 +19,7 @@ % set doc_name = 'quotation' if object.state in ('draft', 'sent') else 'order confirmation' % set is_online = access_action and access_action['type'] == 'ir.actions.act_url' % set access_name = is_online and object.template_id and 'Accept and pay %s online' % doc_name or 'View %s' % doc_name -% set access_url = is_online and access_action['url'] or object.get_signup_url() +% set access_url = is_online and access_action['url'] or '' % if object.partner_id.parent_id: (${object.partner_id.parent_id.name}) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 103ea11fc7a..cd31f17aabc 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -453,6 +453,8 @@ class SaleOrder(models.Model): @api.multi def action_confirm(self): + for order in self.filtered(lambda order: order.partner_id not in order.message_partner_ids): + order.message_subscribe([order.partner_id.id]) for order in self: order.state = 'sale' order.confirmation_date = fields.Datetime.now() diff --git a/addons/website_portal_sale/__manifest__.py b/addons/website_portal_sale/__manifest__.py index f7fb153ab01..553dee9f474 100644 --- a/addons/website_portal_sale/__manifest__.py +++ b/addons/website_portal_sale/__manifest__.py @@ -10,13 +10,15 @@ Add your sales document in the frontend portal. Your customers will be able to connect to their portal to see the list (and the state) of their invoices (pdf report), sales orders and quotations (web pages). """, 'depends': [ - 'portal_sale', + 'sale', 'website_portal', 'website_payment', ], 'data': [ 'views/website_portal_sale_templates.xml', + 'views/sale_order_views.xml', 'security/ir.model.access.csv', + 'security/sale_order_security.xml', ], 'demo': [ 'data/sale_demo.xml' diff --git a/addons/website_portal_sale/models/account_invoice.py b/addons/website_portal_sale/models/account_invoice.py index c16e8c3492d..c754e862623 100644 --- a/addons/website_portal_sale/models/account_invoice.py +++ b/addons/website_portal_sale/models/account_invoice.py @@ -33,3 +33,11 @@ class AccountInvoice(models.Model): 'res_id': self.id, } return super(AccountInvoice, self).get_access_action() + + @api.multi + def get_signup_url(self): + self.ensure_one() + return self.partner_id.with_context(signup_valid=True)._get_signup_url_for_action( + action='/mail/view', + model=self._name, + res_id=self.id)[self.partner_id.id] diff --git a/addons/website_portal_sale/models/sale_order.py b/addons/website_portal_sale/models/sale_order.py index 2602592c787..ff3df80e4d6 100644 --- a/addons/website_portal_sale/models/sale_order.py +++ b/addons/website_portal_sale/models/sale_order.py @@ -47,3 +47,11 @@ class SaleOrder(models.Model): line.qty_to_invoice = line.product_uom_qty - line.qty_invoiced else: line.qty_to_invoice = 0 + + @api.multi + def get_signup_url(self): + self.ensure_one() + return self.partner_id.with_context(signup_valid=True)._get_signup_url_for_action( + action='/mail/view', + model=self._name, + res_id=self.id)[self.partner_id.id] diff --git a/addons/portal_sale/security/portal_sale_security.xml b/addons/website_portal_sale/security/sale_order_security.xml similarity index 100% rename from addons/portal_sale/security/portal_sale_security.xml rename to addons/website_portal_sale/security/sale_order_security.xml diff --git a/addons/portal_sale/views/sale_order_views.xml b/addons/website_portal_sale/views/sale_order_views.xml similarity index 100% rename from addons/portal_sale/views/sale_order_views.xml rename to addons/website_portal_sale/views/sale_order_views.xml