Skip to content

Commit

Permalink
Upgraded permissions for multicompany 23.27
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciocosta committed Apr 19, 2023
1 parent 60b0ad6 commit a7ec230
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion __manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
'name': 'MercadoLibre Publisher / Mercado Libre Odoo Connector',
'summary': 'MercadoLibre Publisher / Mercado Libre Odoo Connector',
'version': '16.0.23.20',
'version': '16.0.23.27',
'author': 'Moldeo Interactive',
'website': 'https://www.moldeointeractive.com',
"category": "Sales",
Expand Down
2 changes: 1 addition & 1 deletion data/parameters_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<record model="ir.rule" id="mercadolibre_questions_comp_rule">
<field name="name">MercadoLibre Questions multi-company</field>
<field name="model_id" ref="model_mercadolibre_questions"/>
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
<field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>

</data>
Expand Down
2 changes: 2 additions & 0 deletions models/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

from .meli_oerp_config import *
from .warning import warning
from . import versions
from .versions import *

import requests

Expand Down
9 changes: 7 additions & 2 deletions models/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,8 +1709,9 @@ def orders_update_order_json( self, data, context=None, config=None, meli=None )


product_related = order.search_meli_product( meli=meli, meli_item=Item['item'], config=config )
if ( product_related and len(product_related)==0 and ('seller_custom_field' in Item['item'] or 'seller_sku' in Item['item'])):

_logger.info("1st attempt: "+str(product_related)+" Item: "+str(Item["item"]) )
if ( ( (not product_related) or len(product_related)==0 ) and ('seller_custom_field' in Item['item'] or 'seller_sku' in Item['item'])):
_logger.info("2nd attempt: "+str(Item["item"]) )
#1ST attempt "seller_sku" or "seller_custom_field"
seller_sku = ('seller_sku' in Item['item'] and Item['item']['seller_sku']) or ('seller_custom_field' in Item['item'] and Item['item']['seller_custom_field'])
if (seller_sku):
Expand All @@ -1721,10 +1722,14 @@ def orders_update_order_json( self, data, context=None, config=None, meli=None )
seller_sku = ('seller_custom_field' in Item['item'] and Item['item']['seller_custom_field'])
if (seller_sku):
product_related = product_obj.search([('default_code','=ilike',seller_sku)])
else:
seller_sku = ('seller_sku' in Item['item'] and Item['item']['seller_sku']) or ('seller_custom_field' in Item['item'] and Item['item']['seller_custom_field'])


#TODO: 3RD attempt using barcode
#if (not product_related):
# search using item attributes GTIN and SELLER_SKU
_logger.info("2nd attempt: "+str(Item["item"]) + " seller_sku:"+str(seller_sku))

if (len(product_related)):
_logger.info("order product related by seller_custom_field and default_code:"+str(seller_sku) )
Expand Down
4 changes: 2 additions & 2 deletions models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def _meli_set_product_price( self, product_template, meli_price, force_variant=F

if (pli_tpl or pli_var):
#_logger.info("Updating price")
return_val = pl.price_get( self.id, 1.0 )
return_val = get_price_from_pl(pricelist=pl, product=self,quantity=1.0)
if (pl.id in return_val):
old_price = return_val[pl.id]
if pli_tpl:
Expand Down Expand Up @@ -616,7 +616,7 @@ def set_meli_price( self, meli=None, config=None, plist=None ):
new_price = product.lst_price

if (pl):
return_val = pl.price_get(product.id,1.0)
return_val = get_price_from_pl(pricelist=pl, product=product,quantity=1.0)
if pl.id in return_val:
new_price = return_val[pl.id]
_logger.info("return_val: "+str(return_val))
Expand Down
19 changes: 10 additions & 9 deletions models/product_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,16 +509,17 @@ def product_template_import(self, context=None):
csv_report = ""

sep = ""
for field in full_report[0]:
csv_report_header+= sep+str(field)
sep = ";"

for sync in full_report:
sep = ""
for field in sync:
csv_report+= sep+'"'+str(sync[field])+'"'
if full_report:
for field in full_report[0]:
csv_report_header+= sep+str(field)
sep = ";"
csv_report+= "\n"

for sync in full_report:
sep = ""
for field in sync:
csv_report+= sep+'"'+str(sync[field])+'"'
sep = ";"
csv_report+= "\n"

csv_report_attachment_last = self.report_import or self.env["ir.attachment"].search([('res_id','=',self.id)], order='id desc', limit=1 )
if (csv_report_attachment_last):
Expand Down
1 change: 1 addition & 0 deletions models/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class mercadolibre_questions(models.Model):

name = fields.Char(string="Name")
posting_id = fields.Many2one("mercadolibre.posting","Posting")
company_id = fields.Many2one("res.company",string="Empresa")
#product_id = fields.Many2one("product.product","Product")
question_id = fields.Char('Question Id')
date_created = fields.Date('Creation date')
Expand Down
7 changes: 7 additions & 0 deletions models/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
order_message_type = "notification"
product_message_type = "notification"

#price from pricelist
def get_price_from_pl( pricelist, product, quantity ):
pl = pricelist
return_val = {}
return_val[pl.id] = pl._get_product_price(product=product,quantity=quantity)
return return_val

#Autocommit
def Autocommit( self, act=False ):
return False
Expand Down
7 changes: 7 additions & 0 deletions security/meli_oerp_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
<field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>


<record model="ir.rule" id="mercadolibre_questions_comp_rule">
<field name="name">MercadoLibre Questions multi-company</field>
<field name="model_id" ref="model_mercadolibre_questions"/>
<field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>

</odoo>

0 comments on commit a7ec230

Please sign in to comment.