송장에서 선택한 통화로 금액을 표시하는 송장 라인에 이미 금액 필드가 있습니다. 동일한 금액을 기준 통화로 변환하고 기준 통화 기호가있는 송장 라인에 기준 통화 금액을 표시하고 싶습니다.
이를 위해 아래와 같이 기본 통화에 대한 새로운 many2one 필드를 추가했습니다.
base_currency_id = fields.Many2one('res.currency', default=lambda self: self.invoice_id.company_id.currency_id.id)
그런 다음 다음과 같이 기본 통화로 금액을 계산하기 위해 새로운 부동 필드를 추가했습니다.
@api.onchange('price_subtotal', 'invoice_id.currency_id')
def compute_amount_in_base_currency(self):
company_currency = self.invoice_id.company_id.currency_id
for l in self:
amount_in_base = l.currency_id.compute(l.price_subtotal, company_currency)
l.amount_in_base = amount_in_base
amount_in_base = fields.Float('Base Amount', readonly=True, compute='compute_amount_in_base_currency')
xml 파일에서 base_currency_id
필드를 추가 하고 보이지 않게 만들었습니다. 그런 다음 및로 amount_in_base
뷰 에 필드를 추가했습니다 . 내 xml 파일은 다음과 같습니다.widget='monetary'
options="{'currency_field': 'base_currency_id'}"
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='price_subtotal']" position="after">
<field name="base_currency_id" invisible="True"/>
<field name="amount_in_base" widget="monetary" options="{'currency_field': 'base_currency_id'}"/>
</xpath>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다