OpenSPP / openspp-modules

OpenSPP Odoo modules
https://openspp.org
GNU Lesser General Public License v3.0
25 stars 10 forks source link

Fix create function in farmer registry base #569

Open reichie020212 opened 2 weeks ago

reichie020212 commented 2 weeks ago

Fix the create function in the file spp_farmer_registry_base/models/farm.py since it breaks the function of res.partner model to create multiple records in one function. below is the sample code that will produce an error

self.env["res.partner"].create([{"name": "Test 1"}, {"name": "Test 2"}])

This is a major bug that will break other modules as well if this module is installed.

below is the create function that needs to fix

    @api.model_create_multi
    def create(self, vals):
        farm = super().create(vals)
        if farm.is_group:
            self.create_update_farmer(farm)
        elif not farm.is_group and farm.is_registrant:
            self.update_farmer(farm)

        return farm
reichie020212 commented 1 week ago

Estimate Dev Time:

Optimistic: 8 hours Pessimistic: 12 hours