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

How to add data to the Total Amount in Sales Quotation

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
modulespythonxmlcustomizenewbie
1 Responder
9731 Visualizações
Avatar
Jayson Wu

Hi,

I'm trying to add 2 more fields on "Sales Quotation" (Shipping and Bank Charges). I'm done with adding the said fields to the form. Now, my problem is, my float fields are not recognized by the function that I created which would add everything up (Total Amount + Shipping + Bank Charges). I've tried adding a number to the Total Amount function and it successfully adds that number.

Here are my codes:

sales_quotation.py

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
import time
from openerp import pooler
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import openerp.addons.decimal_precision as dp
from openerp import netsvc

class sale_order(osv.osv):

    def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
        res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context)
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id]['amount_total'] += 0 **If I tried to replace 0 with a number it adds up, but if I use res[order.id]['banks'] or res[order.id]['shiping'] it won't add up.**
        return res
    
    def _get_order(self, cr, uid, ids, context=None):
        result = {}
        for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
            result[line.order_id.id] = True
        return result.keys()
        
    _inherit = 'sale.order'
    _columns = {
        'amount_total': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string= 'Total', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help= "The total amount"),
        'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help="The amount without tax"),
        'shiping': fields.float('Shiping'),
        'banks': fields.float('Banking'),
    }
sale_order()

sales_quotation_view.xml

<openerp>
    <data>
        <record model="ir.ui.view" id="view_order_form2_inherit">
            <field name="name">sale.order.inherit2</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                    <field name="amount_untaxed" position="before">
                        <group class="oe_subtotal_footer oe_right" colspan="2" name="custom_added">
                            <field name="shiping" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                            <field name="banks" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                        </group>
                    </field>
            </field>
        </record>
    </data>
</openerp>

Thanks!

 

Edit:

I also tried to change the fields Shiping and Banks from fields.float().

        'shiping': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help="The shipping charge"),

        'banks': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help="The bank charge amount"),

and replace the computation by:

res[order.id]['amount_total'] += res[order.id]['shiping'] + res[order.id]['banks']

and since if we change the field.float to fields.function the field becomes read only so I added readonly="0" to the xml view.

The shiping and banks are now adding up to the amount total, however, if I apply changes to the shiping and banks, it is not registering (so only the first value of shiping and banks are the ones who are added to the amount total) .

0
Avatar
Cancelar
Jayson Wu
Autor

@prakash Hi I tried your code, but it is still not adding. Unfortunately, there are no error messages.

Jayson Wu
Autor

@prakash, it is now adding. However, I can only do it once. If I typed another value to the boxes, and pressed udpate, it will not change.

Avatar
Prakash
Melhor resposta

Try the below code:-

 

 def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
        res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context)
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id]['amount_total'] += order.amount_total + order.banks + order.shipping
        return res

1
Avatar
Cancelar
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
Update Existing Module To Newest Version in Odoo 12 Resolvido
modules python xml update_xml odoo12
Avatar
Avatar
1
nov. 20
5449
Why I can't see my custom module file
modules newbie
Avatar
Avatar
1
jul. 23
3462
How to customize with a custom module? Resolvido
modules customize
Avatar
Avatar
Avatar
Avatar
Avatar
6
abr. 23
34369
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
dez. 23
13922
how to remove first empty element from fields.selection Resolvido
python xml
Avatar
Avatar
Avatar
3
jul. 22
24344
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