콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
질문이 마감되었습니다 이유 : not enough information given to provide help
작성자 Hoang Long VU 있음 2024년 11월 12일 02시 38분 23초
1 회신
661 화면

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
5월 25
688
1
4월 25
583
0
3월 25
454
1
2월 25
482
0
2월 25
598