Add attn to address

Closes #14633
This commit is contained in:
Cédric Krier
2026-02-27 12:55:11 +01:00
parent 661920f4db
commit a51a6249c0
15 changed files with 31 additions and 37 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add attn to address
* Add support for Python 3.14
* Remove support for Python 3.9
* Add a menu entry for party identifiers
+3
View File
@@ -34,6 +34,7 @@ class Address(
party_name = fields.Char(
"Party Name",
help="If filled, replace the name of the party for address formatting")
attn = fields.Char("Attn")
street = fields.Function(fields.Text(
"Street",
@@ -263,6 +264,8 @@ class Address(
if context.get('address_attention_party', False):
substitutions['attn'] = (
context['address_attention_party'].full_name)
else:
substitutions['attn'] = getattr(self, 'attn', None) or ''
for key, value in list(substitutions.items()):
substitutions[key.upper()] = value.upper()
substitutions.update(self._get_street_substitutions())
+3 -2
View File
@@ -1285,11 +1285,12 @@ class Erase(Wizard):
['type', 'code'],
[None, '****']),
(Address, [('party', '=', party_id)], True,
['street_unstructured', 'street_name', 'building_name',
['party_name', 'attn',
'street_unstructured', 'street_name', 'building_name',
'building_number', 'unit_number', 'floor_number',
'room_number', 'post_box', 'private_bag', 'post_office',
'postal_code', 'city', 'country', 'subdivision'],
[None] * 14),
[None] * 16),
(ContactMechanism, [('party', '=', party_id)], True,
['type', 'value', 'name', 'comment'],
['other', '****', None, None]),
+3
View File
@@ -4,8 +4,11 @@ this repository contains the full copyright notices and license terms. -->
<form col="6">
<label name="party"/>
<field name="party" colspan="5"/>
<label name="party_name"/>
<field name="party_name"/>
<label name="attn"/>
<field name="attn"/>
<group colspan="2" col="-1" id="checkboxes">
<label name="active"/>
<field name="active"
@@ -4,8 +4,11 @@ this repository contains the full copyright notices and license terms. -->
<form col="6">
<label name="party"/>
<field name="party" colspan="5"/>
<label name="party_name"/>
<field name="party_name"/>
<label name="attn"/>
<field name="attn"/>
<group colspan="2" col="-1" id="checkboxes">
<label name="active"/>
<field name="active"
+1
View File
@@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<tree>
<field name="party" expand="1"/>
<field name="party_name" optional="0"/>
<field name="attn" optional="1"/>
<field name="street_single_line" expand="2"/>
<field name="postal_code"/>
<field name="city"/>
@@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<tree sequence="sequence">
<field name="party" expand="1"/>
<field name="party_name" optional="0"/>
<field name="attn" optional="1"/>
<field name="street_single_line" expand="2"/>
<field name="postal_code"/>
<field name="city"/>
-1
View File
@@ -538,7 +538,6 @@
<text:p text:style-name="P23"/>
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text">&lt;replace text:p=&quot;set_lang(shipment.delivery_address.party.lang)&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text">&lt;replace text:p=&quot;shipment.set_lang(shipment.delivery_address.party.lang)&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text">&lt;shipment.customer.full_name&gt;</text:placeholder></text:p>
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;line in shipment.delivery_address.full_address.split(&apos;\n&apos;)&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P19"><text:placeholder text:placeholder-type="text">&lt;line&gt;</text:placeholder></text:p>
<text:p text:style-name="P19"><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
+1 -1
View File
@@ -3101,7 +3101,7 @@ class DeliveryNote(ShipmentReport):
@classmethod
def execute(cls, ids, data):
with Transaction().set_context(address_with_party=False):
with Transaction().set_context(address_with_party=True):
return super().execute(ids, data)
@classmethod
-16
View File
@@ -419,19 +419,3 @@ class PrintShippingLabel(Wizard):
package_ids.append(package.id)
labels.add(package.shipping_label)
return action, {'ids': package_ids}
def address_name(address, party=None):
"Returns the party name of the address with party name removed"
if party is None:
party = address.party
name = address.party_full_name
for prefix in sorted([
f'{party.full_name} / ',
f'{party.name} / ',
party.full_name,
party.name,
], key=len, reverse=True):
if name.startswith(prefix) and name != prefix:
return name[len(prefix):]
return name
+2 -3
View File
@@ -16,7 +16,6 @@ from trytond.model import fields
from trytond.model.exceptions import AccessError
from trytond.modules.stock_package_shipping.exceptions import (
PackingValidationError)
from trytond.modules.stock_package_shipping.stock import address_name
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.wizard import StateAction, StateTransition, Wizard
@@ -214,8 +213,8 @@ class CreateDPDShipping(Wizard):
else:
street = address.street_name or ''
house_no = address.numbers
name = address_name(address, party)
contact = party.full_name if party.full_name != name else ''
name = address.party_full_name
contact = address.attn or ''
if with_contact and not contact:
contact = party.full_name
shipping_party = {
@@ -10,7 +10,6 @@ from trytond.model import fields
from trytond.model.exceptions import AccessError
from trytond.modules.stock_package_shipping.exceptions import (
PackingValidationError)
from trytond.modules.stock_package_shipping.stock import address_name
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.wizard import StateAction, StateTransition, Wizard
@@ -233,8 +232,8 @@ class ShipmentCreateShippingMyGLS(Wizard):
house_number_info = address.building_name or ''
phone = address.contact_mechanism_get({'phone', 'mobile'}, usage=usage)
email = address.contact_mechanism_get('email', usage=usage)
name = address_name(address, party)
contact_name = party.full_name if party.full_name != name else None
name = address.party_full_name
contact_name = address.attn or ''
return {
'Name': name,
'Street': street_name,
@@ -8,7 +8,6 @@ from math import ceil
from trytond.i18n import gettext
from trytond.model import fields
from trytond.model.exceptions import AccessError
from trytond.modules.stock_package_shipping.stock import address_name
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.wizard import StateAction, StateTransition, Wizard
@@ -149,17 +148,16 @@ class CreateShippingSendcloud(Wizard):
cm = UoM(ModelData.get_id('product', 'uom_centimeter'))
kg = UoM(ModelData.get_id('product', 'uom_kilogram'))
party = shipment.shipping_to
address = shipment.shipping_to_address
phone = address.contact_mechanism_get(
{'phone', 'mobile'}, usage=usage)
email = address.contact_mechanism_get('email', usage=usage)
street_lines = (address.street or '').splitlines()
name = address_name(address, party)
if party.full_name != name:
company_name = name
name = party.full_name
if address.attn:
name = address.attn
company_name = address.party_full_name
else:
name = address.party_full_name
company_name = None
parcel = {
'name': name,
+2 -3
View File
@@ -17,7 +17,6 @@ from trytond.model import fields
from trytond.model.exceptions import AccessError
from trytond.modules.stock_package_shipping.exceptions import (
PackingValidationError)
from trytond.modules.stock_package_shipping.stock import address_name
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.wizard import StateAction, StateTransition, Wizard
@@ -235,8 +234,8 @@ class CreateShippingUPS(Wizard):
}
def get_shipping_party(self, party, address, usage=None):
name = address_name(address, party)
attention_name = party.full_name
name = address.party_full_name
attention_name = address.attn or name
shipping_party = {
'Name': name[:35],
'AttentionName': attention_name[:35],
+5 -2
View File
@@ -137,8 +137,10 @@ class Address(metaclass=PoolMeta):
values = {}
values['party_name'] = remove_forbidden_chars(address['name'] or '')
if address['company']:
values['party_name'] += (
f"({remove_forbidden_chars(address['company'])})")
values['attn'] = values['party_name']
values['party_name'] = remove_forbidden_chars(address['company'])
else:
values['attn'] = ''
values['street'] = '\n'.join(filter(None, [
address['address1'], address['address2']]))
values['city'] = remove_forbidden_chars(address['city'] or '')
@@ -167,6 +169,7 @@ class Address(metaclass=PoolMeta):
def shopify_values(self):
values = {}
values['party_name'] = self.party_name or ''
values['attn'] = self.attn or ''
values['street'] = self.street or ''
values['city'] = self.city or ''
values['postal_code'] = self.postal_code or ''