تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
لقد تم إغلاق هذا السؤال والسبب: not enough information given to provide help
بواسطة Hoang Long VU في 12 نوفمبر, 2024 02:38:23
1 الرد
652 أدوات العرض

Hello, 

Im actually try to make my first custom module. 

But i cant understand where i made an mistake. If someone can give a hand for this. 


Thank you

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
  <record id="sale_order_form_view_inherit" model="ir.ui.view">
    <field name="name">sale.order.form.view.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
      <xpath expr="//header/field[@name='state']" position="replace">
        <field name="state" widget="statusbar" statusbar_visible="draft,sent,waiting,sale"/>
      </xpath>
      <xpath expr="//header" position="inside">
        <button name="action_payment_receive" type="object" string="Confirm Payment"
                attrs="{'invisible': [('state', '!=', 'waiting')]}"/>
      </xpath>
    </field>
  </record>
</odoo>




الصورة الرمزية
إهمال
الكاتب أفضل إجابة
from odoo import models, fields

class SaleOrder(models.Model):
    _inherit = 'sale.order'
    ​state = fields.Selection(selection_add=[('waiting', 'Waiting Payment')])
    def action_confirm(self):
        for order in self:
            if order.payment_term_id.id != 1:             
                super(SaleOrder, order).action_confirm()
            else:
                order.write({'state': 'waiting'})
        return True

    def action_payment_receive(self):
        for order in self:
            super(SaleOrder, order).action_confirm()
        return True
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مايو 25
674
1
أبريل 25
554
0
مارس 25
444
1
فبراير 25
460
0
فبراير 25
587