Tuesday, January 7, 2020
2 changes · master
Resolved issues and error corrections
This change removes a broken address-autocomplete bridge that could incorrectly split street details and disrupt extended address behavior. It also strengthens extended address handling so company and partner street information stays consistent, with clearer tests to reduce future regressions.
Original PR description
PURPOSE Remove partner_autocomplete_address_extended and ensure base_address_extended effectively works. SPECIFICATIONS Commits a6e1eb9 and 8a1815b added among a lot of other things a bridge module…
PURPOSE
Remove partner_autocomplete_address_extended and ensure base_address_extended
effectively works.
SPECIFICATIONS
Commits a6e1eb9 and 8a1815b added among a lot of other things
a bridge module between ``partner_autocomplete`` and ``base_address_extended``.
It is used only to redefine the ``_split_street_with_params`` method from
``base_address_extended``. This method is used to find street name, number and
number2 from an address, given a format coming from the country.
However the override completely fucks up the original method purpose and uses
an hardcoded regex coming out of the blue. Parameters like country format is
not taken into account which is annoying when trying to parse country dependent
data.
Tests from ``base_address_extended`` crash completely when used with the
``partner_autocomplete_address_extended`` implementation.
Considering the original complete specifications from commits
"""
For Name field or M2O, gives a list of companies
Data comes from Odoo IAP Service
"""
Or specs found in the original task ID 1867818 pad
"""
If Extended Address module is installed, the street number should be correctly
splitted Or the complete address is put in street2 if impossible to parse
"""
We think that this implementation is broken by design. Indeed there is no
mention of street2 anywhere in the code, and this implementation ensure street
will never be correctly split. We therefore remove it completely.
In this merge we also
* clean and improve tests in base_address_extended. Purpose is to make tests
easier to understand and more data oriented. Tests about company / partner
address fields are added to ensure coherency;
* reorganize python code of base_address_extended according to guidelines;
* rename compute / inverse methods of base_address_extended;
* remove dead code from base partner model;
See sub commits for more details.
LINKS
Task ID 2158302
PR #42678Deleting records that automatically remove related items now goes through Odoo's normal cleanup process. This helps ensure related files are removed and dependent totals or stored values are updated correctly, reducing stale data and orphaned attachments.
Original PR description
**Description of the issue/feature this PR addresses:** When you unlink a purchase, the lines are unlink by the `SQL CASCADE` fonction. It is more quicker but the ORM `unlink()` of lines is not…
**Description of the issue/feature this PR addresses:**
When you unlink a purchase, the lines are unlink by the `SQL CASCADE` fonction. It is more quicker but the ORM `unlink()` of lines is not applied. It is an issue, indead the attachments of lines are not unlink, and computed field liked to the lines are not re-computed (computed field in an other model).
This PR propose to unlink cascade records by ORM.
I think there is no case in the Odoo code where this situation exist.
FIX:
- delete attachment of cascade deleted records
- on cascade modified field modified is not apply
IMP:
- full logger of what is delete in database (if you delete a purchase order, you see also log about the purchase line)
- don't clear all the cache
**Exemple**
```python
Order()
_name='order'
lines_ids = fields.One2many('order.line','order_id')
OrderLine():
_name='order.line'
order_id = fields.Many2one('order', ondelete='cascade')
value = fields.Integer(default=10)
file = fields.Binary(attchment=True)
Truc()
_name='truc'
order_line_ids = fields.Many2many('order.line', store=True)
total = fields.Integer(compute='_get_total', store=True, readonly=True)
@api.depends('order_line_ids.value')
def _get_total(self):
for rec in self:
rec.total = sum(rec.order_line_ids.mapped('value')
```
Excecute
`order = self.env['order'].create({'line_ids':[(0,0,{'file': 'dscsd'})]})`
note the id of attachment with SQL request (don't use web UI, it don't show).
`SELECT * FROM ir_attachment`
`order.unlink()`
**Current behavior before PR:**
- make in postgre `SELECT * FROM ir_attachment WHERE id = x`, you can see the attachment (and it still present in the file store.
- `truc.total` is not recomputed
**Desired behavior after PR is merged:**
- file as been deleted.
- `truc.total` is recomputed
**Todo :**
- [x] fix recursion issue
- [x] save cascade field in the registry (remove the `env['ir.module.fields'].search()`)
- [ ] update test
- [x] fix company depend field
- [x] clear more cache (ondelete = 'set nul'
@odony @rco-odoo @nim-odoo
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr