From 1fd4949ddc5868d8ed40f1f9b78ad70294778f2d Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Wed, 29 Nov 2017 13:05:20 +0100 Subject: [PATCH] Feedback: 1127, 1125, 1126 --- ext/custom-addons/dp_custom/__manifest__.py | 1 + ext/custom-addons/dp_custom/data/cron_job.xml | 30 +++++++++++++++++++ .../dp_custom/data/glaser_company_data.xml | 3 +- .../data/tz_austria_company_data.xml | 3 +- .../dp_custom/models/res_partner.py | 9 +++++- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 ext/custom-addons/dp_custom/data/cron_job.xml diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 769c3272..3888954f 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -38,6 +38,7 @@ 'data/dp_custom_data.xml', 'data/glaser_company_data.xml', 'data/tz_austria_company_data.xml', + 'data/cron_job.xml', 'views/dp_custom_views.xml', 'views/res_line_views.xml', 'views/res_partner_views.xml', diff --git a/ext/custom-addons/dp_custom/data/cron_job.xml b/ext/custom-addons/dp_custom/data/cron_job.xml new file mode 100644 index 00000000..9b39351e --- /dev/null +++ b/ext/custom-addons/dp_custom/data/cron_job.xml @@ -0,0 +1,30 @@ + + + + Export Portal Prices TZ + + + + 1 + days + -1 + + code + model.cron_export_portal_prices() + + + + + Export Portal Prices Glaser + + + + 1 + days + -1 + + code + model.cron_export_portal_prices() + + + diff --git a/ext/custom-addons/dp_custom/data/glaser_company_data.xml b/ext/custom-addons/dp_custom/data/glaser_company_data.xml index d8de0f1c..3d091758 100644 --- a/ext/custom-addons/dp_custom/data/glaser_company_data.xml +++ b/ext/custom-addons/dp_custom/data/glaser_company_data.xml @@ -32,7 +32,8 @@ (4,ref('stock.group_stock_manager')), (4,ref('base.group_system')), (4,ref('base.group_partner_manager')), - (4,ref('account.group_account_user'))]"/> + (4,ref('account.group_account_user')), + (4,ref('queue_job.group_queue_job_manager'))]"/> diff --git a/ext/custom-addons/dp_custom/data/tz_austria_company_data.xml b/ext/custom-addons/dp_custom/data/tz_austria_company_data.xml index 5b8cafe9..2866fdc5 100644 --- a/ext/custom-addons/dp_custom/data/tz_austria_company_data.xml +++ b/ext/custom-addons/dp_custom/data/tz_austria_company_data.xml @@ -12,7 +12,8 @@ (4,ref('stock.group_stock_manager')), (4,ref('base.group_system')), (4,ref('base.group_partner_manager')), - (4,ref('account.group_account_user'))]"/> + (4,ref('account.group_account_user')), + (4,ref('queue_job.group_queue_job_manager'))]"/> diff --git a/ext/custom-addons/dp_custom/models/res_partner.py b/ext/custom-addons/dp_custom/models/res_partner.py index de046354..ad2fdbb3 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -139,6 +139,13 @@ class Partner(models.Model): else: return super(Partner, self)._get_specified_fields() + @api.model + def cron_export_portal_prices(self): + partners = self.search([('portal_export_pending', '=', True), ('company_id', '=', self.env.user.company_id.id)]) + for partner in partners: + self.with_delay().job_export_portal_price(partner) + partner.portal_export_pending = False + @api.multi @job def job_export_portal_price(self, partner_id): @@ -148,7 +155,7 @@ class Partner(models.Model): data = {'portal_id': partner_id.portal_id, 'rules': [] } - for item in pricelist.itemd_ids: + for item in pricelist.items_ids: if item.compute_price == 'percentage' and item.applied_on in ['3_global', '2_product_category', '1_product']: category_code = item.product_tmpl_id.categ_id.code if item.applied_on == '2_product_category' else False