minor fix products
This commit is contained in:
parent
1fd3a71d33
commit
9ddeae7219
|
@ -7,6 +7,7 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
build/
|
build/
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
# Compiled Java class files
|
# Compiled Java class files
|
||||||
*.class
|
*.class
|
||||||
|
|
|
@ -29,6 +29,8 @@ class MercadoLibre(SaleWebChannel):
|
||||||
super(MercadoLibre, cls).__setup__()
|
super(MercadoLibre, cls).__setup__()
|
||||||
cls._error_messages.update({
|
cls._error_messages.update({
|
||||||
'product_not_found': ('Product Not Found'),
|
'product_not_found': ('Product Not Found'),
|
||||||
|
'product_generic_not_found': ('Product Generic Not Found, Verify in Configuration'),
|
||||||
|
# 'product_generic': ('The sale will be created with generic product "%s"')
|
||||||
})
|
})
|
||||||
|
|
||||||
def _get_context(self):
|
def _get_context(self):
|
||||||
|
@ -176,6 +178,8 @@ class MercadoLibre(SaleWebChannel):
|
||||||
sales = Sale.search([
|
sales = Sale.search([
|
||||||
('reference', '=', str(sale_['id']))
|
('reference', '=', str(sale_['id']))
|
||||||
])
|
])
|
||||||
|
# print(sales[0].number)
|
||||||
|
|
||||||
if sales:
|
if sales:
|
||||||
if len(sales) == 1 and sale_['status'] == 'cancelled':
|
if len(sales) == 1 and sale_['status'] == 'cancelled':
|
||||||
sale = sales[0]
|
sale = sales[0]
|
||||||
|
@ -233,20 +237,28 @@ class MercadoLibre(SaleWebChannel):
|
||||||
for line in sale_items:
|
for line in sale_items:
|
||||||
item = line['item']
|
item = line['item']
|
||||||
sku_code = item['seller_sku']
|
sku_code = item['seller_sku']
|
||||||
if sku_code.count('+') > 0:
|
if sku_code:
|
||||||
codes = sku_code.split('+')
|
if sku_code.count('+') > 0:
|
||||||
line['unit_price'] = Decimal(round((line['unit_price'] / 2), 2))
|
codes = sku_code.split('+')
|
||||||
|
line['unit_price'] = Decimal(round((line['unit_price'] / 2), 2))
|
||||||
|
else:
|
||||||
|
codes = [sku_code]
|
||||||
|
products = Product.search([
|
||||||
|
('code', 'in', codes),
|
||||||
|
('active', '=', True)
|
||||||
|
])
|
||||||
|
description = ''
|
||||||
|
if not products:
|
||||||
|
products = self._create_product(codes, line)
|
||||||
else:
|
else:
|
||||||
codes = [sku_code]
|
if not self.generic_product:
|
||||||
products = Product.search([
|
return self.raise_user_error('product_generic_not_found')
|
||||||
('code', 'in', codes),
|
products = [self.generic_product]
|
||||||
('active', '=', True)
|
generic = True
|
||||||
])
|
description = ''
|
||||||
description = ''
|
self.raise_user_warning('product_generic',
|
||||||
if not products:
|
'The sale will be created with generic product \n %s'
|
||||||
products = self._create_product(codes, line)
|
% self.generic_product.rec_name)
|
||||||
# self.raise_user_error('product_not_found')
|
|
||||||
# return False
|
|
||||||
for product in products:
|
for product in products:
|
||||||
Tax = _pool.get('account.tax')
|
Tax = _pool.get('account.tax')
|
||||||
un_price = Tax.reverse_compute(line['unit_price'],
|
un_price = Tax.reverse_compute(line['unit_price'],
|
||||||
|
@ -283,7 +295,8 @@ class MercadoLibre(SaleWebChannel):
|
||||||
sale.state = 'cancel'
|
sale.state = 'cancel'
|
||||||
else:
|
else:
|
||||||
Sale.quote([sale])
|
Sale.quote([sale])
|
||||||
sale.state = 'confirmed'
|
if generic:
|
||||||
|
sale.state = 'confirmed'
|
||||||
sale.save()
|
sale.save()
|
||||||
# if shipment_['status'] in ['shipped', 'delivered']:
|
# if shipment_['status'] in ['shipped', 'delivered']:
|
||||||
# self._finish_sale(sale)
|
# self._finish_sale(sale)
|
||||||
|
|
|
@ -46,6 +46,8 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<field name="bonus_product"/>
|
<field name="bonus_product"/>
|
||||||
<label name="invoice_type"/>
|
<label name="invoice_type"/>
|
||||||
<field name="invoice_type"/>
|
<field name="invoice_type"/>
|
||||||
|
<label name="generic_product"/>
|
||||||
|
<field name="generic_product"/>
|
||||||
<label name="tip_product"/>
|
<label name="tip_product"/>
|
||||||
<field name="tip_product"/>
|
<field name="tip_product"/>
|
||||||
<label name="template_notification"/>
|
<label name="template_notification"/>
|
||||||
|
|
|
@ -101,6 +101,11 @@ class SaleWebChannel(Workflow, ModelSQL, ModelView):
|
||||||
'invisible': (Eval('channel_name') != 'shopify'),
|
'invisible': (Eval('channel_name') != 'shopify'),
|
||||||
'readonly': (Eval('state') != 'draft')
|
'readonly': (Eval('state') != 'draft')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
generic_product = fields.Many2One('product.product', 'Generic Product', states={
|
||||||
|
# 'invisible': (Eval('channel_name') != 'shopify'),
|
||||||
|
'readonly': (Eval('state') != 'draft')
|
||||||
|
})
|
||||||
report = fields.Many2One('ir.action.report', 'Report', states=STATES)
|
report = fields.Many2One('ir.action.report', 'Report', states=STATES)
|
||||||
invoice_type = fields.Selection(TYPE_INVOICE, 'Type Invoice',
|
invoice_type = fields.Selection(TYPE_INVOICE, 'Type Invoice',
|
||||||
states=STATES)
|
states=STATES)
|
||||||
|
@ -274,6 +279,7 @@ class SynchronizeChannelOrders(Wizard):
|
||||||
if channel.channel_name == 'mercadolibre':
|
if channel.channel_name == 'mercadolibre':
|
||||||
MercadoLibre = pool.get('sale.web_channel.mercado_libre')
|
MercadoLibre = pool.get('sale.web_channel.mercado_libre')
|
||||||
channel = MercadoLibre(channel)
|
channel = MercadoLibre(channel)
|
||||||
|
|
||||||
if operation == 'especific_order':
|
if operation == 'especific_order':
|
||||||
order_id = self.start.order_id
|
order_id = self.start.order_id
|
||||||
URI = 'https://api.mercadolibre.com/orders/%s?access_token=%s' % (
|
URI = 'https://api.mercadolibre.com/orders/%s?access_token=%s' % (
|
||||||
|
@ -282,10 +288,12 @@ class SynchronizeChannelOrders(Wizard):
|
||||||
if not result:
|
if not result:
|
||||||
self.raise_user_error('error', result)
|
self.raise_user_error('error', result)
|
||||||
sale_created = channel._create_sale(result)
|
sale_created = channel._create_sale(result)
|
||||||
|
generic_code = self.start.channel.generic_product.code if self.start.channel.generic_product else None
|
||||||
|
product_generic = [line.product.code for line in sale_created.lines if line.product.code == generic_code and generic_code]
|
||||||
if sale_created and \
|
if sale_created and \
|
||||||
not sale_created.pack_id and \
|
not sale_created.pack_id and \
|
||||||
sale_created.comment in ['shipped', 'delivered']:
|
sale_created.comment in ['shipped', 'delivered'] and \
|
||||||
|
len(product_generic) < 1:
|
||||||
Sale.process([sale_created])
|
Sale.process([sale_created])
|
||||||
else:
|
else:
|
||||||
date_from = str(self.start.date) + 'T00:00:00.000-00:00'
|
date_from = str(self.start.date) + 'T00:00:00.000-00:00'
|
||||||
|
|
Loading…
Reference in New Issue