[MIG] connector_walmart: to 14.0 (from 12.0)

This commit is contained in:
Jared Kipe
2022-02-03 14:11:05 +00:00
parent b3fdd8b6d0
commit 5528145a20
9 changed files with 4 additions and 47 deletions

View File

@@ -3,7 +3,7 @@
{
'name': 'Walmart Connector',
'version': '12.0.1.2.0',
'version': '14.0.1.0.0',
'category': 'Connector',
'depends': [
'account',

View File

@@ -26,10 +26,8 @@ Resolution:
Check your taxes and fiscal positions configuration and correct them if necessary.</field>
<field name="sequence">30</field>
<field name="model">sale.order</field>
<field name="rule_group">sale</field>
<field name="code">if sale.walmart_bind_ids and abs(sale.amount_total - sale.walmart_bind_ids[0].total_amount) >= 0.01:
failed = True</field>
<field name="active" eval="True"/>
</record>
<record id="excep_wrong_total_amount_tax" model="exception.rule">
@@ -43,11 +41,9 @@ Resolution:
Check your taxes and fiscal positions configuration and correct them if necessary.</field>
<field name="sequence">30</field>
<field name="model">sale.order</field>
<field name="rule_group">sale</field>
<field name="code"># By default, a cent of difference for the tax amount is allowed, feel free to customise it in your own module
if sale.walmart_bind_ids and abs(sale.amount_tax - sale.walmart_bind_ids[0].total_amount_tax) > 0.01:
failed = True</field>
<field name="active" eval="True"/>
</record>
</data>

View File

@@ -14,7 +14,6 @@ class AccountFiscalPosition(models.Model):
is_connector_walmart = fields.Boolean(string='Use Walmart Order Item Rate')
@api.multi
def map_tax(self, taxes, product=None, partner=None, order_line=None):
if not taxes or not self.is_connector_walmart:

View File

@@ -7,7 +7,6 @@ import odoo.addons.decimal_precision as dp
from urllib.parse import parse_qs
from odoo import models, fields, api
from odoo.addons.queue_job.job import job
from odoo.addons.component.core import Component
from odoo.addons.queue_job.exception import RetryableJobError
@@ -50,19 +49,16 @@ class WalmartSaleOrder(models.Model):
required=False,
)
@job(default_channel='root.walmart')
@api.model
def import_batch(self, backend, filters=None):
""" Prepare the import of Sales Orders from Walmart """
return super(WalmartSaleOrder, self).import_batch(backend, filters=filters)
@api.multi
def action_confirm(self):
for order in self:
if order.backend_id.acknowledge_order == 'order_confirm':
self.with_delay().acknowledge_order(order.backend_id, order.external_id)
@job(default_channel='root.walmart')
@api.model
def acknowledge_order(self, backend, external_id):
with backend.work_on(self._name) as work:
@@ -79,7 +75,6 @@ class SaleOrder(models.Model):
string="Walmart Bindings",
)
@api.multi
def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
self.walmart_bind_ids.action_confirm()
@@ -132,8 +127,6 @@ class SaleOrderLine(models.Model):
string="Walmart Bindings",
)
@api.multi
def _compute_tax_id(self):
"""
This overrides core behavior because we need to get the order_line into the order

View File

@@ -134,9 +134,9 @@ class SaleOrderImportMapper(Component):
return {'payment_mode_id': self.backend_record.payment_mode_id.id}
@mapping
def project_id(self, record):
def analytic_account_id(self, record):
if self.backend_record.analytic_account_id:
return {'project_id': self.backend_record.analytic_account_id.id}
return {'analytic_account_id': self.backend_record.analytic_account_id.id}
@mapping
def warehouse_id(self, record):

View File

@@ -3,7 +3,6 @@
import logging
from odoo import api, models, fields
from odoo.addons.queue_job.job import job, related_action
from odoo.addons.component.core import Component
from odoo.addons.queue_job.exception import RetryableJobError
@@ -24,9 +23,6 @@ class WalmartStockPicking(models.Model):
string='Walmart Sale Order',
ondelete='set null')
@job(default_channel='root.walmart')
@related_action(action='related_action_unwrap_binding')
@api.multi
def export_picking_done(self):
""" Export a complete or partial delivery order. """
self.ensure_one()

View File

@@ -73,7 +73,6 @@ class WalmartBackend(models.Model):
)
@contextmanager
@api.multi
def work_on(self, model_name, **kwargs):
self.ensure_one()
walmart_api = Walmart(self.client_id, self.client_secret)
@@ -91,12 +90,10 @@ class WalmartBackend(models.Model):
])
return backends.import_sale_orders()
@api.multi
def import_sale_orders(self):
self._import_from_date('walmart.sale.order', 'import_orders_from_date')
return True
@api.multi
def _import_from_date(self, model_name, from_date_field):
import_start_time = datetime.now()
for backend in self:

View File

@@ -2,7 +2,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, fields
from odoo.addons.queue_job.job import job, related_action
class WalmartBinding(models.AbstractModel):
@@ -27,8 +26,6 @@ class WalmartBinding(models.AbstractModel):
('walmart_uniq', 'unique(backend_id, external_id)', 'A binding already exists for this Walmart ID.'),
]
@job(default_channel='root.walmart')
@related_action(action='related_action_walmart_link')
@api.model
def import_batch(self, backend, filters=None):
""" Prepare the import of records modified on Walmart """
@@ -38,29 +35,9 @@ class WalmartBinding(models.AbstractModel):
importer = work.component(usage='batch.importer')
return importer.run(filters=filters)
@job(default_channel='root.walmart')
@related_action(action='related_action_walmart_link')
@api.model
def import_record(self, backend, external_id, force=False):
""" Import a Walmart record """
with backend.work_on(self._name) as work:
importer = work.component(usage='record.importer')
return importer.run(external_id, force=force)
# @job(default_channel='root.walmart')
# @related_action(action='related_action_unwrap_binding')
# @api.multi
# def export_record(self, fields=None):
# """ Export a record on Walmart """
# self.ensure_one()
# with self.backend_id.work_on(self._name) as work:
# exporter = work.component(usage='record.exporter')
# return exporter.run(self, fields)
#
# @job(default_channel='root.walmart')
# @related_action(action='related_action_walmart_link')
# def export_delete_record(self, backend, external_id):
# """ Delete a record on Walmart """
# with backend.work_on(self._name) as work:
# deleter = work.component(usage='record.exporter.deleter')
# return deleter.run(external_id)

View File

@@ -60,7 +60,7 @@
</p>
<group>
<div>
<label string="Import sale orders since" class="oe_inline"/>
<label for="import_orders_from_date" string="Import sale orders since" class="oe_inline"/>
<field name="import_orders_from_date"
class="oe_inline"
nolabel="1"/>
@@ -93,7 +93,6 @@
<record id="action_walmart_backend" model="ir.actions.act_window">
<field name="name">Walmart Backends</field>
<field name="res_model">walmart.backend</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_walmart_backend_tree"/>
</record>