Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

need porting to odoo 10 please

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
portingodoo9odoo10
2 Respostas
3477 Visualizações
Avatar
Alfie Qashwa

def get_price_by_pricelist(self, cr, uid, kwargs):

        result = {}

        all_pricelists_ids = self.pool.get('product.pricelist').search(

            cr, SUPERUSER_ID, [('currency_id', '=', kwargs['currency_id'])])

        for pricelist_obj in self.pool.get('product.pricelist').browse(cr, SUPERUSER_ID, all_pricelists_ids):

            currency_position = pricelist_obj.currency_id.position

            currency_symbol = pricelist_obj.currency_id.symbol

            values = {}

            for product_obj in self.pool.get('product.product').browse(cr, SUPERUSER_ID, kwargs['product_ids'], context={'pricelist': pricelist_obj.id}):

                if currency_position == 'after':

                    price = str(product_obj.price) + " " + currency_symbol

                else:

                    price = currency_symbol + " " + str(product_obj.price)

                if product_obj.to_weight:

                    price = price + '/Kg'

                values[product_obj.id] = [price, product_obj.price]

            result[pricelist_obj.id] = values

        return result

0
Avatar
Cancelar
Avatar
Dan Čermák
Melhor resposta

Try this:

@api.multi
def get_price_by_pricelist(self, kwargs):
        result = {}

        all_pricelists_ids = self.env['product.pricelist'].search([('currency_id', '=', kwargs['currency_id'])])
        for pricelist_obj in self.env['product.pricelist'].browse(all_pricelists_ids):

            currency_position = pricelist_obj.currency_id.position
            currency_symbol = pricelist_obj.currency_id.symbol
            values = {}

            for product_obj in self.env['product.product'].browse(kwargs['product_ids'], context={'pricelist': pricelist_obj.id}):
                if currency_position == 'after':
                    price = str(product_obj.price) + " " + currency_symbol

                else:
                    price = currency_symbol + " " + str(product_obj.price)

                if product_obj.to_weight:
                    price = price + '/Kg'

                values[product_obj.id] = [price, product_obj.price]

            result[pricelist_obj.id] = values

        return result

You might have to fix the indentation and I have not tested this, as I do not know the context in which this function is called.

Explanation of the changes:

- in odoo > 7 the old function call signature with self, cr, uid is no longer used, instead you use a function decorator (in this case I think @api.multi might be suitable, which tells python that self gets also populated with the database context)
- database searches are no longer performed via self.pool.get ... but with self.env[].search/browse etc.

For further information, see: https://www.odoo.com/documentation/10.0/reference/orm.html

0
Avatar
Cancelar
Avatar
Alfie Qashwa
Autor Melhor resposta
Hello Dan Čermák 


Thank you for your response. I really appreciate that

Well, i did edit the code and it return errors logs:


Odoo Server Error Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 640, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 677, in dispatch result = self._call_function(**self.params) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 333, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 101, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 326, in checked_call result = self.endpoint(*a, **kw) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 935, in __call__ return self.method(*args, **kw) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 506, in response_wrap response = f(*args, **kw) File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 885, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 877, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 681, in call_kw return call_kw_multi(method, model, args, kwargs) File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 672, in call_kw_multi result = method(recs, *args, **kwargs) TypeError: get_price_by_pricelist() takes exactly 2 arguments (1 given)

This file is a part of pos_multi_pricelist odoo 9 by Webkul

If you can help me porting the module, please give me your email and i will send to you.

Thanks

0
Avatar
Cancelar
Dan Čermák

Well, the App claims support for odoo 10 though: https://www.odoo.com/apps/modules/10.0/pos_multi_pricelist/.

Anyway, my guess is, that you can fix the immediate error by changing the function signature from:

def get_price_by_pricelist(self, kwargs):

to:

def get_price_by_pricelist(self, **kwargs):

(This just means, that all remaining function parameters will be saved in the dictionary kwargs.)

However, I think this will not fix everything, as you are querying the dictionary at this point:

kwargs['currency_id']

But the traceback states, that only one parameter was passed (i.e. self). My guess is, that currency_id has to be obtained via different means, either from the context or from a field maybe? This depends too much on the surrounding module, so I am just guessing here.

If you need help with open source software, contact me on github or gitlab (@D4N in both cases).

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
How to show informations hierarchically in views ?
odoo9 odoo10
Avatar
0
jul. 17
3422
So difficult to describe franchising situation in Odoo?
odoo9 odoo10
Avatar
0
mar. 17
3667
To show all stages in Kanban view Resolvido
kanban odoo9 odoo10
Avatar
Avatar
Avatar
Avatar
3
dez. 23
22295
Odoo 10: Change datetime picker options for a field Resolvido
odoo8.0 odoo9 odoo10
Avatar
Avatar
1
mai. 21
11030
Call from one widget to another widget using odoo js. Resolvido
odoo9 odoo10 odoo11
Avatar
Avatar
1
ago. 18
9982
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now