FB1776: SST-02 Fehler anzeigen, Partner korrekt markieren
parent
5ef73ab0fc
commit
92aa4c7d8a
|
|
@ -22,7 +22,7 @@ from odoo.addons.component.core import Component
|
||||||
|
|
||||||
from odoo import fields, models, api, _
|
from odoo import fields, models, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.addons.queue_job.job import job
|
||||||
|
|
||||||
class ProductXCategory(models.Model):
|
class ProductXCategory(models.Model):
|
||||||
_name = 'product.xcategory'
|
_name = 'product.xcategory'
|
||||||
|
|
@ -152,24 +152,15 @@ class ProductPricelistItemEventListener(Component):
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def on_record_write(self, record, fields=None):
|
def on_record_write(self, record, fields=None):
|
||||||
partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)])
|
self.env['product.pricelist.item'].with_delay().job_mark_partner_for_export(record.pricelist_id.id)
|
||||||
for partner in partners:
|
|
||||||
if partner.portal_id and partner.company_type == 'company':
|
|
||||||
partner.portal_export_pending = True
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def on_record_create(self, record, fields=None):
|
def on_record_create(self, record, fields=None):
|
||||||
partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)])
|
self.env['product.pricelist.item'].with_delay().job_mark_partner_for_export(record.pricelist_id.id)
|
||||||
for partner in partners:
|
|
||||||
if partner.portal_id and partner.company_type == 'company':
|
|
||||||
partner.portal_export_pending = True
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def on_record_unlink(self, record):
|
def on_record_unlink(self, record):
|
||||||
partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)])
|
self.env['product.pricelist.item'].with_delay().job_mark_partner_for_export(record.pricelist_id.id)
|
||||||
for partner in partners:
|
|
||||||
if partner.portal_id and partner.company_type == 'company':
|
|
||||||
partner.portal_export_pending = True
|
|
||||||
|
|
||||||
|
|
||||||
class ProductPricelistItem(models.Model):
|
class ProductPricelistItem(models.Model):
|
||||||
|
|
@ -179,3 +170,12 @@ class ProductPricelistItem(models.Model):
|
||||||
('3_global', 'Global'),
|
('3_global', 'Global'),
|
||||||
('2_product_category', ' Product Category'),
|
('2_product_category', ' Product Category'),
|
||||||
('0_product_variant', 'Product Variant')])
|
('0_product_variant', 'Product Variant')])
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@job
|
||||||
|
def job_mark_partner_for_export(self, pricelist_id):
|
||||||
|
partners = self.env['res.partner'].search([('company_type','=','company'),('portal_id','!=',False)])
|
||||||
|
for partner in partners:
|
||||||
|
# Search ist auf die Preisliste nicht möglich, daher wird jeder Partner einzeln verglichen
|
||||||
|
if partner.property_product_pricelist.id == pricelist_id:
|
||||||
|
partner.portal_export_pending = True
|
||||||
|
|
@ -319,13 +319,16 @@ class Partner(models.Model):
|
||||||
'code': code,
|
'code': code,
|
||||||
'discount': 1 - (item.percent_price / 100)
|
'discount': 1 - (item.percent_price / 100)
|
||||||
})
|
})
|
||||||
|
if data:
|
||||||
portal_url = tools.config.get('portal_url')
|
portal_url = tools.config.get('portal_url')
|
||||||
application_id = tools.config.get('portal_secret')
|
application_id = tools.config.get('portal_secret')
|
||||||
response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id,
|
response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id,
|
||||||
data=json.dumps(data))
|
data=json.dumps(data))
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
|
data = response.json()
|
||||||
|
error_string = data.get('errors',[])
|
||||||
raise ValidationError(_('Rabatt konnte nicht gesetzt werden. '
|
raise ValidationError(_('Rabatt konnte nicht gesetzt werden. '
|
||||||
'Status Code: %s, Reason: %s') % (response.status_code, response.reason))
|
'Status Code: %s, Reason: %s') % (response.status_code, error_string))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue