minor fix shopify

This commit is contained in:
Elvis 2023-12-11 11:22:25 -05:00
parent cd02efa318
commit 9474505163
2 changed files with 9 additions and 6 deletions

View File

@ -432,12 +432,13 @@ class Shopify:
self.app_id = web_shop.app_id
self.secret_key = web_shop.secret_key
self.freight_product = web_shop.freight_product
self.invoice_type = web_shop.invoice_type
def _get_context(self):
user_ = self._get_user()
return {
'company': user_.company.id,
'user': user_.user.id,
'user': user_.id,
'shops': [user_.shop.id],
'shop': user_.shop.id,
'language': 'es'
@ -570,7 +571,8 @@ class Shopify:
'invoice_address': Party.address_get(party, type='invoice'),
'shipment_address': Party.address_get(party, type='delivery'),
'description': 'VENTA SHOPIFY ' + sale_['name'],
'channel': self.id,
'web_shop': self.id,
'web_id': str(sale_['id']),
'invoice_type': self.invoice_type,
'pack_id': ''
}])

9
web.py
View File

@ -7,6 +7,7 @@ from .exceptions import ErrorSynchronizingSale
from trytond.i18n import gettext
from trytond.transaction import Transaction
from . mercado_libre import MercadoLibre
from . shopify import Shopify
from . import rappi
@ -274,18 +275,18 @@ class SynchronizeChannelOrders(Wizard):
if not sale.invoices:
Sale.process([sale])
if channel.type == 'shopify':
Shopify = pool.get('sale.web_channel.shopify')
shopify = Shopify(channel)
channel, = Shopify.search([('shop', '=', self.start.shop.id), ])
# channel, = Shopify.search([('shop', '=', self.start.shop.id), ])
if operation == 'especific_order':
order_id = self.start.order_id
URI = 'https://%s:%s@%s/admin/api/2020-10/orders.json?status=any&ids=%s' % (
channel.api_key, channel.password_api, channel.host_name, order_id)
result = Shopify.get_response(URI).json()
result = shopify.get_response(URI).json()
if not result:
raise ErrorSynchronizingSale(
gettext('sale_web_channel.msg_error_synchronizing_sale', s=result))
sale_created = channel._create_sale(result['orders'][0])
sale_created = shopify._create_sale(result['orders'][0])
if sale_created and \
sale_created.description.count('fulfilled'):
Sale.process([sale_created])