Merge branch 'imp/12.0/connector_opencart' into 12.0-test

# Conflicts:
#	.gitmodules
This commit is contained in:
Jared Kipe
2019-12-04 10:36:50 -08:00
7 changed files with 30 additions and 50 deletions

12
.gitmodules vendored
View File

@@ -9,6 +9,12 @@
path = external/hibou-oca/sale-workflow
url = https://github.com/hibou-io/oca-sale-workflow.git
branch = 12.0
[submodule "external/hibou-oca/social"]
path = external/hibou-oca/social
url = https://github.com/hibou-io/oca-social
[submodule "external/camptocamp-cloud-platform"]
path = external/camptocamp-cloud-platform
url = https://github.com/hibou-io/camptocamp-cloud-platform
[submodule "external/hibou-oca/queue"]
path = external/hibou-oca/queue
url = https://github.com/hibou-io/oca-queue.git
@@ -27,9 +33,3 @@
[submodule "external/hibou-oca/stock-logistics-warehouse"]
path = external/hibou-oca/stock-logistics-warehouse
url = https://github.com/hibou-io/oca-stock-logistics-warehouse.git
[submodule "external/hibou-oca/social"]
path = external/hibou-oca/social
url = https://github.com/hibou-io/oca-social
[submodule "external/camptocamp-cloud-platform"]
path = external/camptocamp-cloud-platform
url = https://github.com/hibou-io/camptocamp-cloud-platform

View File

@@ -1,9 +1,5 @@
FROM hibou/hibou-odoo:12.0
USER 0
RUN pip install cachetools==2.1.0 pycrypto
USER 104
COPY --chown=104 . /opt/odoo/hibou-suite
RUN rm /etc/odoo/odoo.conf \
&& cp /opt/odoo/hibou-suite/debian/odoo.conf /etc/odoo/odoo.conf \

View File

@@ -1,9 +1,5 @@
FROM registry.gitlab.com/hibou-io/hibou-odoo/odoo:RELEASE
USER 0
RUN pip install cachetools==2.1.0 pycrypto
USER 104
COPY --chown=104 . /opt/odoo/hibou-suite
RUN rm /etc/odoo/odoo.conf \
&& cp /opt/odoo/hibou-suite/debian/odoo.conf /etc/odoo/odoo.conf \

View File

@@ -17,6 +17,7 @@
'license': 'AGPL-3',
'website': 'https://hibou.io',
'data': [
'data/connector_opencart_data.xml',
'security/ir.model.access.csv',
'views/delivery_views.xml',
'views/opencart_backend_views.xml',

View File

@@ -4,13 +4,13 @@
<record model="ir.cron" id="ir_cron_import_sale_orders" forcecreate="True">
<field name="name">Opencart - Import Sales Orders</field>
<field eval="False" name="active"/>
<field name="active" eval="False"/>
<field name="state">code</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field name="doall" eval="False"/>
<field ref="connector_opencart.model_opencart_backend" name="model_id"/>
<field name="code">model._scheduler_import_sale_orders()</field>
</record>
@@ -27,26 +27,7 @@ Check your taxes and fiscal positions configuration and correct them if necessar
<field name="sequence">30</field>
<field name="model">sale.order</field>
<field name="rule_group">sale</field>
<field name="code">if sale.opencart_bind_ids and abs(sale.amount_total - sale.opencart_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">
<field name="name">Total Tax Amount differs from Opencart</field>
<field name="description">The tax amount computed in Odoo doesn't match with the tax amount in Opencart.
Cause:
The taxes are probably different between Odoo and Opencart. A fiscal position could have changed the final price.
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.opencart_bind_ids and abs(sale.amount_tax - sale.opencart_bind_ids[0].total_amount_tax) > 0.01:
failed = True</field>
<field name="code">failed = sale.opencart_bind_ids and abs(sale.amount_total - sale.opencart_bind_ids[0].total_amount) >= 0.01</field>
<field name="active" eval="True"/>
</record>

View File

@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from copy import deepcopy, copy
from html import unescape
from odoo import fields, _
from odoo.addons.component.core import Component
@@ -65,14 +66,14 @@ class SaleOrderImportMapper(Component):
record = map_record.source
line_builder = self.component(usage='order.line.builder.shipping')
line_builder.price_unit = 0.0
line_builder.price_unit = record.get('shipping_exclude_tax', 0.0)
if values.get('carrier_id'):
carrier = self.env['delivery.carrier'].browse(values['carrier_id'])
line_builder.product = carrier.product_id
line = (0, 0, line_builder.get_line())
values['order_line'].append(line)
return values
def finalize(self, map_record, values):
@@ -120,9 +121,8 @@ class SaleOrderImportMapper(Component):
[('name', '=', record_method)],
limit=1,
)
assert method, ("method %s should exist because the import fails "
"in SaleOrderImporter._before_import when it is "
" missing" % record_method)
if not method:
raise ValueError('Payment Mode named "%s", cannot be found.' % (record_method, ))
return {'payment_mode_id': method.id}
@mapping
@@ -138,8 +138,11 @@ class SaleOrderImportMapper(Component):
return {'warehouse_id': warehouse.id}
@mapping
def shipping_method(self, record):
method = record['shipping_method'] or ''
def shipping_code(self, record):
method = record.get('shipping_code') or record.get('shipping_method')
if not method:
return {'carrier_id': False}
carrier_domain = [('opencart_code', '=', method.strip())]
company = self.options.store.company_id or self.backend_record.company_id
if company:
@@ -149,7 +152,7 @@ class SaleOrderImportMapper(Component):
carrier = self.env['delivery.carrier'].search(carrier_domain, limit=1)
if not carrier:
raise ValueError('Delivery Carrier for method Code "%s", cannot be found.' % (method, ))
return {'carrier_id': carrier.id, 'shipping_method_code': method}
return {'carrier_id': carrier.id}
@mapping
def company_id(self, record):
@@ -328,7 +331,6 @@ class SaleOrderLineImportMapper(Component):
direct = [('quantity', 'product_uom_qty'),
('price', 'price_unit'),
('name', 'name'),
('order_product_id', 'external_id'),
]
@@ -340,13 +342,17 @@ class SaleOrderLineImportMapper(Component):
reference = record['model']
values = {
'default_code': reference,
'name': record.get('name', reference),
'name': unescape(record.get('name', reference)), # unknown if other fields, but have observed &quot; in product names
'type': 'product',
'list_price': record.get('price', 0.0),
'categ_id': self.backend_record.product_categ_id.id,
}
return self._finalize_product_values(record, values)
@mapping
def name(self, record):
return unescape(record['name'])
@mapping
def product_id(self, record):
reference = record['model']

View File

@@ -15,7 +15,7 @@ class HRExpense(models.Model):
raise ValidationError('You must have an assigned vendor to process a Company Paid Expense')
move_line_values = move_line_values_by_expense[expense.id]
for line_values in move_line_values:
new_name = expense.name.split('\n')[0][:64] + (' - ' + str(self.reference) if self.reference else '')
new_name = expense.name.split('\n')[0][:64] + (' - ' + str(expense.reference) if expense.reference else '')
line_values['name'] = new_name[:64]
line_values['partner_id'] = expense.vendor_id.id
return move_line_values_by_expense