odoo13 error creating new product public category (eCommerce) - odoo-13

I have a problem after deleting a product parent public category. Now, to create a new public product category, I get the following error:
The post is missing or has been deleted.
(Entry: product.public.category (682,), User: 2)
Where 682 is the primary category database ID that was deleted.
I've deleted all public categories, but the error is repeated.
How to solve this?
I attach a screenshot.
Screenshot

Related

afterUpdate listener in typeorm does not listen to updates on #UpdateDateColumn - postgres DB

I'm working on a functionality, where in I have an entity called 'Employee' with a few columns like first name, last name, DOB, etc. and two columns:createdAt and updatedAt defined with #CreateDateColumn and #UpdateDateColumn respectively.
My requirement is that, whenever an update operation is performed on this entity, I should be logging the column name that was updated, along with the old and new value that it holds.
I'm performing the update on Employee table using queryRunner.manager.save()
To track the changes,
I'm making use of the entity subscribers 'afterUpdate' event.
Now on performing an update, for e.g. When I change the Name, my Employee entity is correctly updating the name as well as the 'updatedAt' field to current timestamp in DB
However,my 'afterUpdate' listener is only logging the 'name' column with its old and new values.
Its not logging the updatedAt column.
Can anyone please help me understand what's possibly going wrong here?
Entity definition:
...All columns (first name, etc.)
#UpdateDateColumn({name:'updated_at',type:'timestamp',nullable:true})
updatedAt:Date;
Subscriber code:
#EventSubscriber()
export class EmployeeSubscriber implements
EntitySubscriberInterface<EmployeeEntity> {
constructor()
{}
listenTo() {
return EmployeeEntity;
}
afterUpdate(event: UpdateEvent<EmployeeEnitity>){
const {updatedColumns, dataBaseEntity,entity}=event;
updatedColumns.forEach(({propertyName})=>{
//Get the updated column name and old and new values
//col_name = propertyName;
//oldVal= databaseEntity[propertyName as keyof EmployeeEntity] as string,
//newVal= entity?.[propertyName as keyof EmployeeEntity] as string,
})
}
}
I tried using different save operations (via repository, queryRunner, manager), but it didn't work.
Official docs say the event is triggered only on save operation.
If I manually pass the date to updatedAt field, then I am able to get the field within the event handler, but I don't think that's the right approach as manual intervention should not be needed for #UpdateDateColumn

Hybris ModelService remove not removing

I'm trying to remove all the Stock from query products in a cronjob:
List<ProductModel> products = flexibleSearchService.search(GET_SPECIAL_PRODUCTS_QUERY);
for (ProductModel product : products.getResult()) {
modelService.removeAll(product.getStockLevels());
}
If I debug here I can see that all the products have stock, however, after performing the removeAll method from model Service, the Stock is not removed.
How can I fix this?

AutoMapper - Retrieve a different field from a linked source table than the one that links it

I have the following table structure that mixes legacy fields with an updated schema:
Coaster
Id (Int)
ParkId (Int)
Park
Id (int)
UniqueId (Guid)
So, the Coaster and Park tables are linked using the Park.Id field. The UniqueId field is not currently used in the old schema. We are migrating to a clean DB using AutoMapper, and this new schema looks like this:
Coaster
Id (Int)
ParkId (Guid)
Park
Id (Guid)
The problem I am having is doing this using AutoMapper. I've been experimenting with this code:
private ModelMapper()
{
Mapper.Initialize(x =>
{
x.AddProfile<ConvertersMappingProfile>();
});
}
// This is the part that I'm trying to work out
public ConvertersMappingProfile()
{
CreateMap<Park, NewSchema.Park>()
.ForMember(dst => dst.Id, map => map.MapFrom(src => src.ParkId));
}
In the new schema, the Park table's Id matches the old schema's UniqueId.
My question is: Because in the old schema there is no direct link to the UniqueId value of the Park table, how to do I get that value to map to the new schema using the Coaster.ParkId field to Park.Id field mapping?
I used a custom resolve to fix the problem. So I created my resolver, which pulls up a list of the items in the database (which is typically pretty small) to get all the values from the table I need, and retrieves the value. (Pre-refactored code):
public class ParkResolver : IValueResolver<Original.Park, New.Park, string> {
public string Resolve(Original.Park source, New.Park dest, string destMember, ResolutionContext context) {
List<Original.Park> list = new List<Original.Park>();
using (IDbConnection con = new SQLiteConnection(#"Data Source=C:\Users\Me\Documents\Parks.sql;")) {
con.Open();
list = con.Query<Original.Park>($"SELECT * FROM Parks WHERE Id = {source.ParkId}").ToList();
con.Close();
}
return list.FirstOrDefault().UniqueId;
}
}
And I call my custom resolver for the tables I am mapping:
CreateMap<Original.Park, New.Park>()
.ForMember(dst => dst.ParkId, map => map.MapFrom(new ParkResolver()));
Hopefully that will help someone else.

How can I design Jhipster JDL relationship for a simple Region > Country > State > City dropdowns

I couldn't figure out how to make relations between entities make them depended each other.
Is jdl itself enough to have entities like below;
Add New Region:
Region Name
Add New Country:
Region (Dropdown)
Country Name
Add New State:
Region (Dropdown)
Country (Dropdown "List updates with the change of the region)
State Name
Add New City:
Region (Dropdown)
Country (Dropdown "List updates with the change of the region)
State (Dropdown "List updates with the change of the Country)
City Name
Add New Address:
Region (Dropdown)
Country (Dropdown "List updates with the change of the region)
State (Dropdown "List updates with the change of the Country)
City (Dropdown "List updates with the change of the State)
Address
I've tried this;
entity Region {
regionName String required
}
entity Country {
countryName String required
}
entity State {
stateName String required
}
entity City {
cityName String required
}
entity Address {
addressLine String required
}
relationship ManyToOne {
Country{region(regionName)} to Region,
State{country(countryName)} to Country,
City{state(stateName)} to State,
Address{city(cityName)} to City
}
paginate all with infinite-scroll
service all with serviceImpl
This jdl shows only it's parent. I want to create a new address entity with all parents up to region.
If I try to make relationships with all parents, all dropdowns are individual. You can select Asia > USA > Paris.
What is the right way to relate the address with Region, Country, State, City with correct dependencies?
The JDL looks good to me, it's just that JHipster won't generate the client view with transitive relationships. You have to write it manually.
On server side, you can use DTOs to combine all data in one request. Add dto * with mapstruct to the bottom of your JDL and then edit generated mappers.

Droidparts: how to get to autocreated column names in m2m table?

community.
I am just start to use droidparts.
As I got it is cool library. But it has poor documentation, and no comments in code itself.
I am interested in getting elegant approach to use it.
Well suppose, i've created tables items, users, items2users as many-to-many concept.
Tables items and users are trivial. Table items2users is
#Table(name="items2users")
public class ItemsToUsers extends Entity {
#Column
public Item item;
#Column
public User user;
}
So if I need to get answer if my User has Item I do something like that in UserManager class:
public boolean hasItem(Item item) {
Select<ItemsToUsers> select = select().columns(ID).where({HERE_I_NEED_COLUMN_NAME}, Is.EQUAL, user.id);
}
Droidparts made table with fields 'item_id' and 'user_id'. As I understand HERE_I_NEED_FIELD_NAME must be 'user_id'. As I realize it is automatic naming model for this situation?
Well is there some elegant technique to achive this names or I should construct them manually getting 'user' and '_' and 'id'?
By default the column name will be field name + _id, e.g. item_id & user_id in your case. That can be altered through annotation, e.g. #Column(name="some_other_name").

Resources