details:   https://code.tryton.org/tryton/commit/f2c5d67fe779
branch:    default
user:      Cédric Krier <[email protected]>
date:      Mon Feb 16 12:32:35 2026 +0100
description:
        Add payment means to invoices
diffstat:

 modules/account_invoice/CHANGELOG                                |    1 +
 modules/account_invoice/doc/design.rst                           |   25 +-
 modules/account_invoice/invoice.fodt                             |   38 +-
 modules/account_invoice/invoice.py                               |  221 
+++++++++-
 modules/account_invoice/invoice.xml                              |   80 +++
 modules/account_invoice/payment_term.xml                         |    9 +-
 modules/account_invoice/setup.py                                 |    5 +-
 modules/account_invoice/tests/scenario_invoice_payment_means.rst |   71 +++
 modules/account_invoice/tests/test_module.py                     |    1 +
 modules/account_invoice/tryton.cfg                               |    9 +
 modules/account_invoice/view/invoice_form.xml                    |    3 +-
 modules/account_invoice/view/invoice_payment_mean_form.xml       |   10 +
 modules/account_invoice/view/invoice_payment_mean_list.xml       |    7 +
 modules/account_invoice/view/invoice_payment_mean_rule_form.xml  |   16 +
 modules/account_invoice/view/invoice_payment_mean_rule_list.xml  |    8 +
 15 files changed, 475 insertions(+), 29 deletions(-)

diffs (769 lines):

diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/CHANGELOG
--- a/modules/account_invoice/CHANGELOG Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/CHANGELOG Mon Feb 16 12:32:35 2026 +0100
@@ -1,3 +1,4 @@
+* Add payment means to invoices
 * Add an origin invoices field to the invoice
 * Remove default invoice type
 
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/doc/design.rst
--- a/modules/account_invoice/doc/design.rst    Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/doc/design.rst    Mon Feb 16 12:32:35 2026 +0100
@@ -182,9 +182,9 @@
 
    Payment terms are create and managed from the main menu item:
 
-      |Financial --> Configuration --> Payment Terms --> Payment Terms|__
+      |Financial --> Configuration --> Invoice Payments --> Payment Terms|__
 
-      .. |Financial --> Configuration --> Payment Terms --> Payment Terms| 
replace:: :menuselection:`Financial --> Configuration --> Payment Terms --> 
Payment Terms`
+      .. |Financial --> Configuration --> Invoice Payments --> Payment Terms| 
replace:: :menuselection:`Financial --> Configuration --> Invoice Payments --> 
Payment Terms`
       __ https://demo.tryton.org/model/account.invoice.payment_term
 
 Wizards
@@ -206,3 +206,24 @@
    Payment terms can be tested out by opening the main menu item:
 
       :menuselection:`Financial --> Configuration --> Payment Terms --> Test 
Payment Term`
+
+.. _model-account.invoice.payment.mean.rule:
+
+Payment Mean Rule
+=================
+
+The *Payment Mean Rule* stores the payment instruments that are applied
+automatically on `Invoices <model-account.invoice>` without any of them on
+validation or posting.
+The selection is based on criteria such as the `company
+<company:model-company.company>` and the `currency
+<currency:model-currency.currency>` of the invoice.
+
+.. seealso::
+
+   Payment means rules are created and managed from the main menu item:
+
+      |Financial --> Configuration --> Invoice Payments --> Payment Means 
Rules|__
+
+      .. |Financial --> Configuration --> Invoice Payments --> Payment Means 
Rules| replace:: :menuselection:`Financial --> Configuration --> Invoice 
Payments --> Payment Means Rules`
+      __ https://demo.tryton.org/model/account.invoice.payment.mean.rule
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/invoice.fodt
--- a/modules/account_invoice/invoice.fodt      Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/invoice.fodt      Mon Feb 16 12:32:35 2026 +0100
@@ -2,17 +2,17 @@
 
 <office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text">
  <office:meta>
-  <meta:generator>LibreOffice/25.2.5.2$Linux_X86_64 
LibreOffice_project/520$Build-2
+  <meta:generator>LibreOffice/25.2.7.2$Linux_X86_64 
LibreOffice_project/520$Build-2
   </meta:generator>
   <meta:user-defined meta:name="Info 1" meta:value-type="string"/>
   <meta:user-defined meta:name="Info 2" meta:value-type="string"/>
   <meta:user-defined meta:name="Info 3" meta:value-type="string"/>
   <meta:user-defined meta:name="Info 4" meta:value-type="string"/>
-  <meta:document-statistic meta:page-count="8" meta:table-count="5" 
meta:image-count="0" meta:object-count="0" meta:paragraph-count="129" 
meta:word-count="325" meta:character-count="3870"/>
+  <meta:document-statistic meta:page-count="9" meta:table-count="5" 
meta:image-count="0" meta:object-count="0" meta:paragraph-count="135" 
meta:word-count="336" meta:character-count="3984"/>
  </office:meta>
  <office:settings>
   <config:config-item-set config:name="ooo:view-settings">
-   <config:config-item config:name="ViewAreaTop" 
config:type="long">205105</config:config-item>
+   <config:config-item config:name="ViewAreaTop" 
config:type="long">204893</config:config-item>
    <config:config-item config:name="ViewAreaLeft" 
config:type="long">0</config:config-item>
    <config:config-item config:name="ViewAreaWidth" 
config:type="long">25243</config:config-item>
    <config:config-item config:name="ViewAreaHeight" 
config:type="long">21883</config:config-item>
@@ -21,12 +21,12 @@
    <config:config-item-map-indexed config:name="Views">
     <config:config-item-map-entry>
      <config:config-item config:name="ViewId" 
config:type="string">view2</config:config-item>
-     <config:config-item config:name="ViewLeft" 
config:type="long">20849</config:config-item>
-     <config:config-item config:name="ViewTop" 
config:type="long">217225</config:config-item>
+     <config:config-item config:name="ViewLeft" 
config:type="long">14400</config:config-item>
+     <config:config-item config:name="ViewTop" 
config:type="long">217923</config:config-item>
      <config:config-item config:name="VisibleLeft" 
config:type="long">0</config:config-item>
-     <config:config-item config:name="VisibleTop" 
config:type="long">205105</config:config-item>
+     <config:config-item config:name="VisibleTop" 
config:type="long">204893</config:config-item>
      <config:config-item config:name="VisibleRight" 
config:type="long">25241</config:config-item>
-     <config:config-item config:name="VisibleBottom" 
config:type="long">226986</config:config-item>
+     <config:config-item config:name="VisibleBottom" 
config:type="long">226774</config:config-item>
      <config:config-item config:name="ZoomType" 
config:type="short">0</config:config-item>
      <config:config-item config:name="ViewLayoutColumns" 
config:type="short">1</config:config-item>
      <config:config-item config:name="ViewLayoutBookMode" 
config:type="boolean">false</config:config-item>
@@ -150,7 +150,7 @@
    <config:config-item config:name="UseOldPrinterMetrics" 
config:type="boolean">false</config:config-item>
    <config:config-item config:name="RedlineProtectionKey" 
config:type="base64Binary"/>
    <config:config-item config:name="TabsRelativeToIndent" 
config:type="boolean">true</config:config-item>
-   <config:config-item config:name="Rsid" 
config:type="int">3274672</config:config-item>
+   <config:config-item config:name="Rsid" 
config:type="int">3380794</config:config-item>
    <config:config-item config:name="UpdateFromTemplate" 
config:type="boolean">true</config:config-item>
    <config:config-item config:name="ProtectForm" 
config:type="boolean">false</config:config-item>
    <config:config-item config:name="MsWordCompMinLineHeightByFly" 
config:type="boolean">false</config:config-item>
@@ -628,12 +628,16 @@
   <style:style style:name="P24" style:family="paragraph" 
style:parent-style-name="Text_20_body">
    <style:paragraph-properties fo:text-align="center" 
style:justify-single-word="false"/>
   </style:style>
+  <style:style style:name="P25" style:family="paragraph" 
style:parent-style-name="Table_20_Heading">
+   <style:text-properties officeooo:rsid="003346fa" 
officeooo:paragraph-rsid="003346fa"/>
+  </style:style>
+  <style:style style:name="P26" style:family="paragraph" 
style:parent-style-name="Text_20_body">
+   <style:paragraph-properties fo:text-align="start" 
style:justify-single-word="false"/>
+   <style:text-properties officeooo:paragraph-rsid="003346fa"/>
+  </style:style>
   <style:style style:name="T1" style:family="text">
    <style:text-properties style:text-underline-style="solid" 
style:text-underline-width="auto" style:text-underline-color="font-color"/>
   </style:style>
-  <style:style style:name="T2" style:family="text">
-   <style:text-properties officeooo:rsid="000dd611"/>
-  </style:style>
   <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Frame">
    <style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" 
fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="parallel" 
style:number-wrapped-paragraphs="no-limit" style:vertical-pos="middle" 
style:vertical-rel="baseline" style:horizontal-pos="left" 
style:horizontal-rel="paragraph" draw:opacity="100%" fo:padding="0cm" 
fo:border="none" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true">
     <style:columns fo:column-count="1" fo:column-gap="0cm"/>
@@ -664,7 +668,7 @@
     <text:p text:style-name="P2"><text:placeholder 
text:placeholder-type="text">&lt;/if&gt;</text:placeholder></text:p>
     <text:p text:style-name="P3"><text:placeholder 
text:placeholder-type="text">&lt;choose&gt;</text:placeholder></text:p>
     <text:p text:style-name="P3"><text:placeholder 
text:placeholder-type="text">&lt;when 
test=&quot;invoice.company.logo&quot;&gt;</text:placeholder></text:p>
-    <text:p text:style-name="P3"><draw:frame draw:style-name="fr1" 
draw:name="image:invoice.company.get_logo_cm(7, 3.5)" 
text:anchor-type="as-char" svg:width="7.001cm" draw:z-index="7">
+    <text:p text:style-name="P3"><draw:frame draw:style-name="fr1" 
draw:name="image:invoice.company.get_logo_cm(7, 3.5)" 
text:anchor-type="as-char" svg:width="7.001cm" draw:z-index="8">
       <draw:text-box fo:min-height="3cm">
        <text:p text:style-name="P4"/>
       </draw:text-box>
@@ -1087,14 +1091,20 @@
       <text:p text:style-name="P23"><text:soft-page-break/>Reference</text:p>
       <text:p text:style-name="P24"><text:placeholder 
text:placeholder-type="text">&lt;invoice.customer_payment_reference&gt;</text:placeholder></text:p>
       <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;/if&gt;</text:placeholder></text:p>
+      <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;if 
test=&quot;invoice.payment_means&quot;&gt;</text:placeholder></text:p>
+      <text:p text:style-name="P25">Payment Means</text:p>
+      <text:p text:style-name="P26"><text:placeholder 
text:placeholder-type="text">&lt;for each=&quot;mean in 
invoice.payment_means&quot;&gt;</text:placeholder></text:p>
+      <text:p text:style-name="P26"><text:placeholder 
text:placeholder-type="text">&lt;mean.rec_name&gt;</text:placeholder></text:p>
+      <text:p text:style-name="P26"><text:placeholder 
text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
+      <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;/if&gt;</text:placeholder></text:p>
      </table:table-cell>
      <table:covered-table-cell/>
     </table:table-row>
    </table:table>
    <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;/if&gt;</text:placeholder></text:p>
-   <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;for each=&quot;comment in (invoice.comment or 
&apos;&apos;).split(&apos;\n&apos;)&quot;&gt;</text:placeholder></text:p>
+   <text:p 
text:style-name="Text_20_body"><text:soft-page-break/><text:placeholder 
text:placeholder-type="text">&lt;for each=&quot;comment in (invoice.comment or 
&apos;&apos;).split(&apos;\n&apos;)&quot;&gt;</text:placeholder></text:p>
    <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;comment&gt;</text:placeholder></text:p>
    <text:p text:style-name="Text_20_body"><text:placeholder 
text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
   </office:text>
  </office:body>
-</office:document>
+</office:document>
\ No newline at end of file
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/invoice.py
--- a/modules/account_invoice/invoice.py        Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/invoice.py        Mon Feb 16 12:32:35 2026 +0100
@@ -18,8 +18,8 @@
 from trytond import backend, config
 from trytond.i18n import gettext
 from trytond.model import (
-    ChatMixin, DeactivableMixin, Index, ModelSQL, ModelView, Unique, Workflow,
-    dualmethod, fields, sequence_ordered)
+    ChatMixin, DeactivableMixin, Index, MatchMixin, ModelSQL, ModelView,
+    Unique, Workflow, dualmethod, fields, sequence_ordered)
 from trytond.model.exceptions import AccessError
 from trytond.modules.account.exceptions import AccountMissing
 from trytond.modules.account.tax import TaxableMixin
@@ -27,7 +27,7 @@
     employee_field, reset_employee, set_employee)
 from trytond.modules.currency.fields import Monetary
 from trytond.modules.product import price_digits
-from trytond.pool import Pool
+from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Bool, Eval, Id, If
 from trytond.report import Report
 from trytond.rpc import RPC
@@ -250,6 +250,9 @@
     payment_term = fields.Many2One(
         'account.invoice.payment_term', "Payment Term",
         ondelete='RESTRICT', states=_states)
+    payment_means = fields.One2Many(
+        'account.invoice.payment.mean', 'invoice', "Payment Means",
+        states=_states)
     alternative_payees = fields.Many2Many(
         'account.invoice.alternative_payee', 'invoice', 'party',
         "Alternative Payee", states=_states,
@@ -1485,6 +1488,26 @@
             pattern.setdefault('country', self.invoice_address.country.id)
         return self.company.get_tax_identifier(pattern)
 
+    @classmethod
+    def set_payment_means(cls, invoices):
+        pool = Pool()
+        PaymentMean = pool.get('account.invoice.payment.mean')
+        PaymentMeanRule = pool.get('account.invoice.payment.mean.rule')
+        payment_means = []
+        rules = PaymentMeanRule.search([])
+        for invoice in invoices:
+            if invoice.type != 'out':
+                continue
+            if invoice.payment_means:
+                continue
+            pattern = PaymentMeanRule.pattern_from_invoice(invoice)
+            for rule in rules:
+                if rule.match(pattern):
+                    payment_mean = PaymentMean.from_rule(rule)
+                    payment_mean.invoice = invoice
+                    payment_means.append(payment_mean)
+        PaymentMean.save(payment_means)
+
     @property
     def invoice_report_versioned(self):
         return self.state in {'posted', 'paid'} and self.type == 'out'
@@ -1560,6 +1583,14 @@
 
     @classmethod
     def view_attributes(cls):
+        pool = Pool()
+        PaymentMean = pool.get('account.invoice.payment.mean')
+        if not PaymentMean.get_instruments():
+            payment_means = [
+                ('/form//field[@name="payment_means"]', 'invisible', '1'),
+                ]
+        else:
+            payment_means = []
         return super().view_attributes() + [
             ('/form//field[@name="comment"]', 'spell', Eval('party_lang')),
             ('/tree', 'visual',
@@ -1570,7 +1601,15 @@
                         & (Eval('amount_to_pay_today', 0) < 0)),
                     'danger',
                     If(Eval('state') == 'cancelled', 'muted', ''))),
-            ]
+            ] + payment_means
+
+    @classmethod
+    def index_set_field(cls, name):
+        index = super().index_set_field(name)
+        if name == 'payment_means':
+            # payment means domain depends on alternative_payees
+            index = cls.index_set_field('alternative_payees') + 1
+        return index
 
     @classmethod
     def check_modification(cls, mode, invoices, values=None, external=False):
@@ -1974,6 +2013,7 @@
 
         invoices_in = cls.browse([i for i in invoices if i.type == 'in'])
         cls.set_number(invoices_in)
+        cls.set_payment_means(invoices)
         cls._store_cache(invoices)
         moves = []
         for invoice in invoices_in:
@@ -2045,6 +2085,7 @@
         context = transaction.context
 
         cls.set_number(invoices)
+        cls.set_payment_means(invoices)
         cls._store_cache(invoices)
         moves = []
         for invoice in invoices:
@@ -3396,6 +3437,178 @@
         return line
 
 
+class PaymentMean(ModelSQL, ModelView):
+    __name__ = 'account.invoice.payment.mean'
+
+    invoice = fields.Many2One('account.invoice', "Invoice", required=True)
+    payees = fields.Function(
+        fields.Many2Many(
+            'party.party', None, None, "Payees",
+            context={
+                'company': Eval('company', -1),
+                }),
+        'on_change_with_payees')
+    payers = fields.Function(
+        fields.Many2Many(
+            'party.party', None, None, "Payers",
+            context={
+                'company': Eval('company', -1),
+                }),
+        'on_change_with_payers')
+    company = fields.Function(
+        fields.Many2One('company.company', "Company"),
+        'on_change_with_company')
+    instrument = fields.Reference(
+        "Instrument", 'get_instruments', required=True)
+
+    @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.__access__.add('invoice')
+
+    @fields.depends(
+        'invoice', '_parent_invoice.type',
+        '_parent_invoice.company', '_parent_invoice.party',
+        '_parent_invoice.alternative_payees')
+    def on_change_with_payees(self, name=None):
+        payees = []
+        if self.invoice:
+            if self.invoice.type == 'out':
+                if self.invoice.company:
+                    payees.append(self.invoice.company.party)
+            elif self.invoice.type == 'in':
+                if self.invoice.party:
+                    payees.append(self.invoice.party)
+                if self.invoice.alternative_payees:
+                    payees.extend(self.invoice.alternative_payees)
+        return payees
+
+    @fields.depends(
+        'invoice', '_parent_invoice.type',
+        '_parent_invoice.company', '_parent_invoice.party',
+        '_parent_invoice.alternative_payees')
+    def on_change_with_payers(self, name=None):
+        payers = []
+        if self.invoice:
+            if self.invoice.type == 'in':
+                if self.invoice.company:
+                    payers.append(self.invoice.company.party)
+            elif self.invoice.type == 'out':
+                if self.invoice.party:
+                    payers.append(self.invoice.party)
+                if self.invoice.alternative_payees:
+                    payers.extend(self.invoice.alternative_payees)
+        return payers
+
+    @fields.depends('invoice', '_parent_invoice.company')
+    def on_change_with_company(self, name=None):
+        return self.invoice.company if self.invoice else None
+
+    @classmethod
+    def _get_instruments(cls):
+        return []
+
+    @classmethod
+    def get_instruments(cls):
+        pool = Pool()
+        Model = pool.get('ir.model')
+        Rule = pool.get('account.invoice.payment.mean.rule')
+        get_name = Model.get_name
+        instruments = Rule.get_instruments()
+        for model in cls._get_instruments():
+            instruments.append((model, get_name(model)))
+        return instruments
+
+    def get_rec_name(self, name):
+        return self.instrument.rec_name
+
+    @classmethod
+    def from_rule(cls, rule):
+        return cls(instrument=rule.instrument)
+
+
+class PaymentMean_Bank(metaclass=PoolMeta):
+    __name__ = 'account.invoice.payment.mean'
+
+    @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.instrument.domain['bank.account'] = [
+            ('owners.id', 'in', Eval('payees', [])),
+            ]
+
+    def get_rec_name(self, name):
+        name = super().get_rec_name(name)
+        if self.instrument.__name__ == 'bank.account':
+            for number in self.instrument.numbers:
+                name = f'{number.type_string}: {number.number}'
+                break
+            else:
+                name = ''
+        return name
+
+
+class PaymentMeanRule(sequence_ordered(), MatchMixin, ModelSQL, ModelView):
+    __name__ = 'account.invoice.payment.mean.rule'
+
+    company = fields.Many2One('company.company', "Company", required=True)
+    currency = fields.Many2One('currency.currency', "Currency")
+    payee = fields.Function(
+        fields.Many2One(
+            'party.party', "Payee",
+            context={
+                'company': Eval('company', -1),
+                }),
+        'on_change_with_payee')
+    instrument = fields.Reference(
+        "Instrument", 'get_instruments', required=True)
+
+    @classmethod
+    def default_company(cls):
+        return Transaction().context.get('company')
+
+    @fields.depends('company')
+    def on_change_with_payee(self, name=None):
+        return self.company.party if self.company else None
+
+    @classmethod
+    def _get_instruments(cls):
+        return []
+
+    @classmethod
+    def get_instruments(cls):
+        pool = Pool()
+        Model = pool.get('ir.model')
+        get_name = Model.get_name
+        instruments = []
+        for model in cls._get_instruments():
+            instruments.append((model, get_name(model)))
+        return instruments
+
+    @classmethod
+    def pattern_from_invoice(cls, invoice):
+        return {
+            'company': invoice.company.id,
+            'currency': invoice.currency.id,
+            }
+
+
+class PaymentMeanRule_Bank(metaclass=PoolMeta):
+    __name__ = 'account.invoice.payment.mean.rule'
+
+    @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.instrument.domain['bank.account'] = [
+            ('owners.id', '=', Eval('payee', -1)),
+            ]
+
+    @classmethod
+    def _get_instruments(cls):
+        yield from super()._get_instruments()
+        yield 'bank.account'
+
+
 class PaymentMethod(DeactivableMixin, ModelSQL, ModelView):
     __name__ = 'account.invoice.payment.method'
     company = fields.Many2One('company.company', "Company", required=True)
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/invoice.xml
--- a/modules/account_invoice/invoice.xml       Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/invoice.xml       Mon Feb 16 12:32:35 2026 +0100
@@ -9,6 +9,12 @@
             sequence="20"
             id="menu_invoices"/>
 
+        <menuitem
+            name="Invoice Payments"
+            parent="account.menu_account_configuration"
+            sequence="50"
+            id="menu_payments_configuration"/>
+
         <record model="ir.action.wizard" id="wizard_pay">
             <field name="name">Pay Invoice</field>
             <field name="wiz_name">account.invoice.pay</field>
@@ -397,6 +403,80 @@
             <field name="name">invoice_tax_tree_sequence</field>
         </record>
 
+        <record model="ir.ui.view" id="invoice_payment_mean_view_form">
+            <field name="model">account.invoice.payment.mean</field>
+            <field name="type">form</field>
+            <field name="name">invoice_payment_mean_form</field>
+        </record>
+
+        <record model="ir.ui.view" id="invoice_payment_mean_view_list">
+            <field name="model">account.invoice.payment.mean</field>
+            <field name="type">tree</field>
+            <field name="name">invoice_payment_mean_list</field>
+        </record>
+
+        <record model="ir.ui.view" id="invoice_payment_mean_rule_view_form">
+            <field name="model">account.invoice.payment.mean.rule</field>
+            <field name="type">form</field>
+            <field name="name">invoice_payment_mean_rule_form</field>
+        </record>
+
+        <record model="ir.ui.view" id="invoice_payment_mean_rule_view_list">
+            <field name="model">account.invoice.payment.mean.rule</field>
+            <field name="type">tree</field>
+            <field name="name">invoice_payment_mean_rule_list</field>
+        </record>
+
+        <record model="ir.action.act_window" 
id="act_invoice_payment_mean_rule_form">
+            <field name="name">Payment Means Rules</field>
+            <field name="res_model">account.invoice.payment.mean.rule</field>
+        </record>
+        <record model="ir.action.act_window.view" 
id="act_invoice_payment_mean_rule_form_view1">
+            <field name="sequence" eval="10"/>
+            <field name="view" ref="invoice_payment_mean_rule_view_list"/>
+            <field name="act_window" ref="act_invoice_payment_mean_rule_form"/>
+        </record>
+        <record model="ir.action.act_window.view" 
id="act_invoice_payment_mean_rule_form_view2">
+            <field name="sequence" eval="20"/>
+            <field name="view" ref="invoice_payment_mean_rule_view_form"/>
+            <field name="act_window" ref="act_invoice_payment_mean_rule_form"/>
+        </record>
+        <menuitem
+            parent="menu_payments_configuration"
+            action="act_invoice_payment_mean_rule_form"
+            sequence="20"
+            id="menu_invoice_payment_mean_rule"/>
+
+        <record model="ir.model.access" id="access_invoice_payment_mean_rule">
+            <field name="model">account.invoice.payment.mean.rule</field>
+            <field name="perm_read" eval="True"/>
+            <field name="perm_write" eval="False"/>
+            <field name="perm_create" eval="False"/>
+            <field name="perm_delete" eval="False"/>
+        </record>
+
+        <record model="ir.model.access" 
id="access_invoice_payment_mean_rule_account">
+            <field name="model">account.invoice.payment.mean.rule</field>
+            <field name="group" ref="account.group_account"/>
+            <field name="perm_read" eval="True"/>
+            <field name="perm_write" eval="True"/>
+            <field name="perm_create" eval="True"/>
+            <field name="perm_delete" eval="True"/>
+        </record>
+
+        <record model="ir.rule.group" 
id="rule_group_invoice_payment_mean_rule_companies">
+            <field name="name">User in companies</field>
+            <field name="model">account.invoice.payment.mean.rule</field>
+            <field name="global_p" eval="True"/>
+        </record>
+        <record model="ir.rule" id="rule_invoice_payment_mean_rule_companies">
+            <field
+                name="domain"
+                eval="[('company', 'in', Eval('companies', []))]"
+                pyson="1"/>
+            <field name="rule_group" 
ref="rule_group_invoice_payment_mean_rule_companies"/>
+        </record>
+
         <record model="ir.ui.view" id="pay_start_view_form">
             <field name="model">account.invoice.pay.start</field>
             <field name="type">form</field>
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/payment_term.xml
--- a/modules/account_invoice/payment_term.xml  Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/payment_term.xml  Mon Feb 16 12:32:35 2026 +0100
@@ -3,11 +3,6 @@
 this repository contains the full copyright notices and license terms. -->
 <tryton>
     <data>
-        <menuitem
-            name="Payment Terms"
-            parent="account.menu_account_configuration"
-            sequence="50"
-            id="menu_payment_terms_configuration"/>
         <record model="ir.ui.view" id="payment_term_view_form">
             <field name="model">account.invoice.payment_term</field>
             <field name="type">form</field>
@@ -33,7 +28,7 @@
             <field name="act_window" ref="act_payment_term_form"/>
         </record>
         <menuitem
-            parent="menu_payment_terms_configuration"
+            parent="menu_payments_configuration"
             action="act_payment_term_form"
             sequence="10"
             id="menu_payment_term_form"/>
@@ -106,7 +101,7 @@
             <field name="action" ref="wizard_payment_term_test"/>
         </record>
         <menuitem
-            parent="menu_payment_terms_configuration"
+            parent="menu_payments_configuration"
             action="wizard_payment_term_test"
             sequence="90"
             id="menu_payment_term_test"/>
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/setup.py
--- a/modules/account_invoice/setup.py  Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/setup.py  Mon Feb 16 12:32:35 2026 +0100
@@ -50,7 +50,10 @@
         requires.append(get_require_version('trytond_%s' % dep))
 requires.append(get_require_version('trytond'))
 
-tests_require = [get_require_version('proteus')]
+tests_require = [
+    get_require_version('proteus'),
+    get_require_version('trytond_bank'),
+    ]
 
 setup(name=name,
     version=version,
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/tests/scenario_invoice_payment_means.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account_invoice/tests/scenario_invoice_payment_means.rst  Mon Feb 
16 12:32:35 2026 +0100
@@ -0,0 +1,71 @@
+==============================
+Invoice Payment Means Scenario
+==============================
+
+Imports::
+
+    >>> from proteus import Model
+    >>> from trytond.modules.account.tests.tools import (
+    ...     create_chart, create_fiscalyear, get_accounts)
+    >>> from trytond.modules.account_invoice.tests.tools import (
+    ...     set_fiscalyear_invoice_sequences)
+    >>> from trytond.modules.company.tests.tools import create_company, 
get_company
+    >>> from trytond.tests.tools import activate_modules, assertEqual, 
assertFalse
+
+Activate modules::
+
+    >>> config = activate_modules(
+    ...     ['account_invoice', 'bank'], create_company, create_chart)
+
+    >>> BankAccount = Model.get('bank.account')
+    >>> Invoice = Model.get('account.invoice')
+    >>> Party = Model.get('party.party')
+    >>> PaymentMeanRule = Model.get('account.invoice.payment.mean.rule')
+
+    >>> company = get_company()
+
+Create fiscal year::
+
+    >>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear())
+    >>> fiscalyear.click('create_period')
+
+Get accounts::
+
+    >>> accounts = get_accounts()
+
+Create party::
+
+    >>> customer = Party(name='Party')
+    >>> customer.save()
+
+Setup payment mean rules::
+
+    >>> bank_account1 = BankAccount(owners=[Party(company.party.id)])
+    >>> _ = bank_account1.numbers.new(type='other', number='12345')
+    >>> bank_account1.save()
+
+    >>> bank_account2 = BankAccount(owners=[Party(company.party.id)])
+    >>> _ = bank_account1.numbers.new(type='other', number='67890')
+    >>> bank_account2.save()
+
+    >>> payment_mean_rule = PaymentMeanRule(instrument=bank_account1)
+    >>> payment_mean_rule.save()
+
+Create invoice without payment means::
+
+    >>> invoice = Invoice(type='out')
+    >>> invoice.party = customer
+    >>> assertFalse(invoice.payment_means)
+    >>> invoice.click('validate_invoice')
+    >>> payment_mean, = invoice.payment_means
+    >>> assertEqual(payment_mean.instrument, bank_account1)
+
+Create invoice with payment means::
+
+    >>> invoice = Invoice(type='out')
+    >>> invoice.party = customer
+    >>> payment_mean = invoice.payment_means.new()
+    >>> payment_mean.instrument = bank_account2
+    >>> invoice.click('post')
+    >>> payment_mean, = invoice.payment_means
+    >>> assertEqual(payment_mean.instrument, bank_account2)
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/tests/test_module.py
--- a/modules/account_invoice/tests/test_module.py      Thu Feb 12 11:09:23 
2026 +0100
+++ b/modules/account_invoice/tests/test_module.py      Mon Feb 16 12:32:35 
2026 +0100
@@ -40,6 +40,7 @@
         ModuleTestCase):
     'Test AccountInvoice module'
     module = 'account_invoice'
+    extras = ['bank']
 
     @with_transaction()
     def test_payment_term(self):
diff -r 8397d8703b17 -r f2c5d67fe779 modules/account_invoice/tryton.cfg
--- a/modules/account_invoice/tryton.cfg        Thu Feb 12 11:09:23 2026 +0100
+++ b/modules/account_invoice/tryton.cfg        Mon Feb 16 12:32:35 2026 +0100
@@ -9,6 +9,8 @@
     party
     product
     res
+extras_depend:
+    bank
 xml:
     invoice.xml
     payment_term.xml
@@ -31,6 +33,8 @@
     invoice.InvoiceLine
     invoice.InvoiceLineTax
     invoice.InvoiceTax
+    invoice.PaymentMean
+    invoice.PaymentMeanRule
     invoice.InvoiceEdocumentStart
     invoice.InvoiceEdocumentResult
     invoice.PayInvoiceStart
@@ -70,3 +74,8 @@
     account.CancelMoves
 report:
     invoice.InvoiceReport
+
+[register bank]
+model:
+    invoice.PaymentMean_Bank
+    invoice.PaymentMeanRule_Bank
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/view/invoice_form.xml
--- a/modules/account_invoice/view/invoice_form.xml     Thu Feb 12 11:09:23 
2026 +0100
+++ b/modules/account_invoice/view/invoice_form.xml     Mon Feb 16 12:32:35 
2026 +0100
@@ -83,7 +83,8 @@
 
             <label name="customer_payment_reference"/>
             <field name="customer_payment_reference"/>
-            <newline/>
+
+            <field name="payment_means" colspan="4"/>
 
             <label name="amount_to_pay_today"/>
             <field name="amount_to_pay_today"/>
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/view/invoice_payment_mean_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account_invoice/view/invoice_payment_mean_form.xml        Mon Feb 
16 12:32:35 2026 +0100
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<form>
+    <label name="invoice"/>
+    <field name="invoice" colspan="3"/>
+
+    <label name="instrument"/>
+    <field name="instrument" colspan="3"/>
+</form>
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/view/invoice_payment_mean_list.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account_invoice/view/invoice_payment_mean_list.xml        Mon Feb 
16 12:32:35 2026 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tree editable="1">
+    <field name="invoice" expand="1"/>
+    <field name="instrument" expand="2"/>
+</tree>
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/view/invoice_payment_mean_rule_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account_invoice/view/invoice_payment_mean_rule_form.xml   Mon Feb 
16 12:32:35 2026 +0100
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<form>
+    <label name="company"/>
+    <field name="company"/>
+    <label name="sequence"/>
+    <field name="sequence"/>
+
+    <label name="currency"/>
+    <field name="currency"/>
+    <newline/>
+
+    <label name="instrument"/>
+    <field name="instrument"/>
+</form>
diff -r 8397d8703b17 -r f2c5d67fe779 
modules/account_invoice/view/invoice_payment_mean_rule_list.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account_invoice/view/invoice_payment_mean_rule_list.xml   Mon Feb 
16 12:32:35 2026 +0100
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tree sequence="sequence">
+    <field name="company" expand="1" optional="1"/>
+    <field name="currency"/>
+    <field name="instrument" expand="2"/>
+</tree>


Reply via email to